You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "agchang (via GitHub)" <gi...@apache.org> on 2023/03/30 19:14:48 UTC

[GitHub] [arrow] agchang opened a new pull request, #34808: GH-34807: [Go] Handle `io.EOF` when reading parquet footer size and magic bytes

agchang opened a new pull request, #34808:
URL: https://github.com/apache/arrow/pull/34808

   <!--
   Thanks for opening a pull request!
   If this is your first pull request you can find detailed information on how 
   to contribute here:
     * [New Contributor's Guide](https://arrow.apache.org/docs/dev/developers/guide/step_by_step/pr_lifecycle.html#reviews-and-merge-of-the-pull-request)
     * [Contributing Overview](https://arrow.apache.org/docs/dev/developers/overview.html)
   
   
   If this is not a [minor PR](https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#Minor-Fixes). Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose
   
   Opening GitHub issues ahead of time contributes to the [Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.) of the Apache Arrow project.
   
   Then could you also rename the pull request title in the following format?
   
       GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
   
   or
   
       MINOR: [${COMPONENT}] ${SUMMARY}
   
   In the case of PARQUET issues on JIRA the title also supports:
   
       PARQUET-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
   
   -->
   
   ### Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   ### What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   ### Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   ### Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please uncomment the line below and explain which changes are breaking.
   -->
   <!-- **This PR includes breaking changes to public APIs.** -->
   
   <!--
   Please uncomment the line below (and provide explanation) if the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld). We use this to highlight fixes to issues that may affect users without their knowledge. For this reason, fixing bugs that cause errors don't count, since those are usually obvious.
   -->
   <!-- **This PR contains a "Critical Fix".** -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] ursabot commented on pull request #34808: GH-34807: [Go] Handle `io.EOF` when reading parquet footer size and magic bytes

Posted by "ursabot (via GitHub)" <gi...@apache.org>.
ursabot commented on PR #34808:
URL: https://github.com/apache/arrow/pull/34808#issuecomment-1502346799

   Benchmark runs are scheduled for baseline = 2e6c13d49956bd852ef7a70d94d3957599775e7c and contender = e50729acbdeba510b58b090d1cde7e166964e22d. e50729acbdeba510b58b090d1cde7e166964e22d is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/745fcee46bb648148f12396cc1d10dca...e33f925e4c8c42f4a574b73e1d771278/)
   [Finished :arrow_down:0.42% :arrow_up:0.06%] [test-mac-arm](https://conbench.ursa.dev/compare/runs/73d888d2f7d544f1b2c6cff3777b894b...dcac003f37b941239eecf17a5ea21e74/)
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/3fc770a6cf4b4de88e5b3fabd03b5ed5...041a1a008fac49008b8747c8262c0ddb/)
   [Finished :arrow_down:0.22% :arrow_up:0.0%] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/7e93839e14bc4063a35bf36621508bf0...aab7090090474407a0de28c9cb82b0b7/)
   Buildkite builds:
   [Finished] [`e50729ac` ec2-t3-xlarge-us-east-2](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/2664)
   [Finished] [`e50729ac` test-mac-arm](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/2697)
   [Finished] [`e50729ac` ursa-i9-9960x](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/2662)
   [Finished] [`e50729ac` ursa-thinkcentre-m75q](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/2688)
   [Finished] [`2e6c13d4` ec2-t3-xlarge-us-east-2](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/2663)
   [Finished] [`2e6c13d4` test-mac-arm](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/2696)
   [Finished] [`2e6c13d4` ursa-i9-9960x](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/2661)
   [Finished] [`2e6c13d4` ursa-thinkcentre-m75q](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/2687)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] zeroshade commented on a diff in pull request #34808: GH-34807: [Go] Handle `io.EOF` when reading parquet footer size and magic bytes

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #34808:
URL: https://github.com/apache/arrow/pull/34808#discussion_r1159955339


##########
go/parquet/file/file_reader_test.go:
##########
@@ -19,6 +19,9 @@ package file_test
 import (
 	"bytes"
 	"encoding/binary"
+	"github.com/apache/arrow/go/v12/parquet"
+	"github.com/apache/arrow/go/v12/parquet/schema"
+	"github.com/stretchr/testify/require"

Review Comment:
   can you run `go fmt` on this / `goimports` so it reorders the imports sorting them appropriately? that's likely what's causing the failing dev script CI tests, these are getting ordered differently resulting in the diffs not being what is expected.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] zeroshade commented on pull request #34808: GH-34807: [Go] Handle `io.EOF` when reading parquet footer size and magic bytes

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #34808:
URL: https://github.com/apache/arrow/pull/34808#issuecomment-1499252542

   @agchang the import order / `go fmt` issue is the only thing left on here, I'm happy to merge once that's addressed.
   
   Thanks again for this!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] zeroshade commented on a diff in pull request #34808: GH-34807: [Go] Handle `io.EOF` when reading parquet footer size and magic bytes

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #34808:
URL: https://github.com/apache/arrow/pull/34808#discussion_r1161812580


##########
go/parquet/file/file_reader_test.go:
##########
@@ -19,6 +19,9 @@ package file_test
 import (
 	"bytes"
 	"encoding/binary"
+	"github.com/apache/arrow/go/v12/parquet"
+	"github.com/apache/arrow/go/v12/parquet/schema"
+	"github.com/stretchr/testify/require"

Review Comment:
   you needed to remove the empty line and then use goimports to sort the imports. I've done so and pushed the fix.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] zeroshade commented on a diff in pull request #34808: GH-34807: [Go] Handle `io.EOF` when reading parquet footer size and magic bytes

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #34808:
URL: https://github.com/apache/arrow/pull/34808#discussion_r1159956127


##########
go/parquet/file/file_reader_test.go:
##########
@@ -19,6 +19,9 @@ package file_test
 import (
 	"bytes"
 	"encoding/binary"
+	"github.com/apache/arrow/go/v12/parquet"
+	"github.com/apache/arrow/go/v12/parquet/schema"
+	"github.com/stretchr/testify/require"

Review Comment:
   I should really add a workflow for the bot to auto-run the formatting like we have for C++ and clang-format...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] agchang commented on a diff in pull request #34808: GH-34807: [Go] Handle `io.EOF` when reading parquet footer size and magic bytes

Posted by "agchang (via GitHub)" <gi...@apache.org>.
agchang commented on code in PR #34808:
URL: https://github.com/apache/arrow/pull/34808#discussion_r1159030926


##########
go/parquet/file/file_reader_test.go:
##########
@@ -271,6 +286,31 @@ func (p *PageSerdeSuite) TestCompression() {
 	}
 }
 
+func TestWithEOFReader(t *testing.T) {
+	sink := encoding.NewBufferWriter(0, memory.DefaultAllocator)
+	serializer := thrift.NewThriftSerializer()
+	fields := schema.FieldList{
+		schema.NewInt32Node("int_col", parquet.Repetitions.Required, -1),
+	}
+	root, _ := schema.NewGroupNode("schema", parquet.Repetitions.Repeated, fields, -1)
+	schema := schema.NewSchema(root)
+	props := parquet.NewWriterProperties(parquet.WithVersion(parquet.V2_LATEST))
+	builder := metadata.NewFileMetadataBuilder(schema, props, nil)
+	fileMetaData, _ := builder.Finish()
+
+	size, _ := serializer.Serialize(fileMetaData, sink, nil)
+
+	binary.Write(sink, binary.LittleEndian, uint32(size))
+	magic := []byte("PAR1")
+	sink.Write(magic)
+	buf := sink.Finish()
+	defer buf.Release()

Review Comment:
   Appreciate the help! Much cleaner. Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] zeroshade commented on pull request #34808: GH-34807: [Go] Handle `io.EOF` when reading parquet footer size and magic bytes

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #34808:
URL: https://github.com/apache/arrow/pull/34808#issuecomment-1496495255

   Is there more you intend to do here? I'd say that a unit test which uses an implementation that returns the io.EOF and confirms this fixes it would be good. Otherwise this seems fine to me if you think it's ready for review.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] github-actions[bot] commented on pull request #34808: GH-34807: [Go] Handle `io.EOF` when reading parquet footer size and magic bytes

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #34808:
URL: https://github.com/apache/arrow/pull/34808#issuecomment-1490802590

   * Closes: #34807


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] agchang commented on a diff in pull request #34808: GH-34807: [Go] Handle `io.EOF` when reading parquet footer size and magic bytes

Posted by "agchang (via GitHub)" <gi...@apache.org>.
agchang commented on code in PR #34808:
URL: https://github.com/apache/arrow/pull/34808#discussion_r1161912109


##########
go/parquet/file/file_reader_test.go:
##########
@@ -19,6 +19,9 @@ package file_test
 import (
 	"bytes"
 	"encoding/binary"
+	"github.com/apache/arrow/go/v12/parquet"
+	"github.com/apache/arrow/go/v12/parquet/schema"
+	"github.com/stretchr/testify/require"

Review Comment:
   Ah, thanks for fixing.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] agchang commented on pull request #34808: GH-34807: [Go] Handle `io.EOF` when reading parquet footer size and magic bytes

Posted by "agchang (via GitHub)" <gi...@apache.org>.
agchang commented on PR #34808:
URL: https://github.com/apache/arrow/pull/34808#issuecomment-1496749172

   > Is there more you intend to do here? I'd say that a unit test which uses an implementation that returns the io.EOF and confirms this fixes it would be good. Otherwise this seems fine to me if you think it's ready for review.
   
   I added a test. I wasn't sure of the best way to get a buffer to an underlying valid parquet file for testing purposes, so I pieced together things from other tests -- let me know if there's a better way.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] github-actions[bot] commented on pull request #34808: GH-34807: [Go] Handle `io.EOF` when reading parquet footer size and magic bytes

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #34808:
URL: https://github.com/apache/arrow/pull/34808#issuecomment-1490802644

   :warning: GitHub issue #34807 **has been automatically assigned in GitHub** to PR creator.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] agchang commented on a diff in pull request #34808: GH-34807: [Go] Handle `io.EOF` when reading parquet footer size and magic bytes

Posted by "agchang (via GitHub)" <gi...@apache.org>.
agchang commented on code in PR #34808:
URL: https://github.com/apache/arrow/pull/34808#discussion_r1161314562


##########
go/parquet/file/file_reader_test.go:
##########
@@ -19,6 +19,9 @@ package file_test
 import (
 	"bytes"
 	"encoding/binary"
+	"github.com/apache/arrow/go/v12/parquet"
+	"github.com/apache/arrow/go/v12/parquet/schema"
+	"github.com/stretchr/testify/require"

Review Comment:
   Hmm, still have failing checks, I ran:
   `go fmt -d file_reader.go file_reader_test.go` and see no diffs 🤔 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] zeroshade commented on a diff in pull request #34808: GH-34807: [Go] Handle `io.EOF` when reading parquet footer size and magic bytes

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #34808:
URL: https://github.com/apache/arrow/pull/34808#discussion_r1158695566


##########
go/parquet/file/file_reader_test.go:
##########
@@ -271,6 +286,31 @@ func (p *PageSerdeSuite) TestCompression() {
 	}
 }
 
+func TestWithEOFReader(t *testing.T) {
+	sink := encoding.NewBufferWriter(0, memory.DefaultAllocator)
+	serializer := thrift.NewThriftSerializer()
+	fields := schema.FieldList{
+		schema.NewInt32Node("int_col", parquet.Repetitions.Required, -1),
+	}
+	root, _ := schema.NewGroupNode("schema", parquet.Repetitions.Repeated, fields, -1)
+	schema := schema.NewSchema(root)
+	props := parquet.NewWriterProperties(parquet.WithVersion(parquet.V2_LATEST))
+	builder := metadata.NewFileMetadataBuilder(schema, props, nil)
+	fileMetaData, _ := builder.Finish()
+
+	size, _ := serializer.Serialize(fileMetaData, sink, nil)
+
+	binary.Write(sink, binary.LittleEndian, uint32(size))
+	magic := []byte("PAR1")
+	sink.Write(magic)
+	buf := sink.Finish()
+	defer buf.Release()

Review Comment:
   You should be able to easily do something like:
   
   ```go
   root, _ := schema.NewGroupNode("schema", parquet.Repetitions.Repeated, schema.FieldList{
           schema.NewInt32Node("int_col", parquet.Repetitions.Required, -1)}, -1)
   props := parquet.NewWriterProperties(parquet.WithVersion(parquet.V2_LATEST)
   
   var sink bytes.Buffer
   wr := file.NewParquetWriter(&sink, root, file.WithWriterProps(props))
   require.NoError(t, wr.Close())
   
   r := bytes.NewReader(buf.Bytes())
   _, err := file.NewParquetReader(testReader{Reader: r})
   assert.NoError(t, err)
   ```
   And just make sure that without your change the test fails.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] agchang commented on a diff in pull request #34808: GH-34807: [Go] Handle `io.EOF` when reading parquet footer size and magic bytes

Posted by "agchang (via GitHub)" <gi...@apache.org>.
agchang commented on code in PR #34808:
URL: https://github.com/apache/arrow/pull/34808#discussion_r1161307565


##########
go/parquet/file/file_reader_test.go:
##########
@@ -19,6 +19,9 @@ package file_test
 import (
 	"bytes"
 	"encoding/binary"
+	"github.com/apache/arrow/go/v12/parquet"
+	"github.com/apache/arrow/go/v12/parquet/schema"
+	"github.com/stretchr/testify/require"

Review Comment:
   Done! Thanks for the pointer.
   
   > I should really add a workflow for the bot to auto-run the formatting like we have for C++ and clang-format...
   
   I can take a look if you guys need help on the go front :-)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] zeroshade merged pull request #34808: GH-34807: [Go] Handle `io.EOF` when reading parquet footer size and magic bytes

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade merged PR #34808:
URL: https://github.com/apache/arrow/pull/34808


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org