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

[GitHub] [arrow-rs] tustvold opened a new pull request, #4327: Don't split record across pages (#3680)

tustvold opened a new pull request, #4327:
URL: https://github.com/apache/arrow-rs/pull/4327

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #3680
   
   # 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.
   -->
   
   Whilst the parquet specification never clearly documents this, an implicit consequence of the row counts in data page v2, and the offset index, is that a row cannot be split across multiple pages.
   
   # 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 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 add the `breaking change` label.
   -->
   


-- 
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-rs] alamb commented on a diff in pull request #4327: Don't split record across pages (#3680)

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #4327:
URL: https://github.com/apache/arrow-rs/pull/4327#discussion_r1213053147


##########
parquet/src/column/writer/mod.rs:
##########
@@ -308,6 +308,17 @@ impl<'a, E: ColumnValueEncoder> GenericColumnWriter<'a, E> {
         max: Option<&E::T>,
         distinct_count: Option<u64>,
     ) -> Result<usize> {
+        // Check if number of definition levels is the same as number of repetition levels.
+        if let (Some(def), Some(rep)) = (def_levels, rep_levels) {

Review Comment:
   Is there any way to test this error condition (and the one below it)? 



##########
parquet/tests/arrow_writer_layout.rs:
##########
@@ -502,3 +503,45 @@ fn test_string() {
         },
     });
 }
+
+#[test]
+fn test_list() {

Review Comment:
   I ran this test without the changes in this PR and verified it failed:
   
   ```
   
   test test_list ... FAILED
   
   failures:
   
   ---- test_list stdout ----
   thread 'test_list' panicked at 'assertion failed: `(left == right)`
     left: `11`,
    right: `10`: index page count mismatch', parquet/tests/arrow_writer_layout.rs:95:13
   stack backtrace:
      0: rust_begin_unwind
                at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:579:5
      1: core::panicking::panic_fmt
                at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/panicking.rs:64:14
      2: core::panicking::assert_failed_inner
                at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/panicking.rs:251:23
      3: core::panicking::assert_failed
                at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/panicking.rs:211:5
      4: arrow_writer_layout::assert_layout
                at ./tests/arrow_writer_layout.rs:95:13
      5: arrow_writer_layout::do_test
                at ./tests/arrow_writer_layout.rs:77:5
      6: arrow_writer_layout::test_list
                at ./tests/arrow_writer_layout.rs:527:5
      7: arrow_writer_layout::test_list::{{closure}}
                at ./tests/arrow_writer_layout.rs:508:16
      8: core::ops::function::FnOnce::call_once
                at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/ops/function.rs:250:5
      9: core::ops::function::FnOnce::call_once
                at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/ops/function.rs:250:5
   note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
   ```
   
   Which seems to imply that the data would be written with one more page.
   
   



-- 
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-rs] tustvold commented on a diff in pull request #4327: Don't split record across pages (#3680)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #4327:
URL: https://github.com/apache/arrow-rs/pull/4327#discussion_r1212198864


##########
parquet/src/column/writer/mod.rs:
##########
@@ -308,6 +308,17 @@ impl<'a, E: ColumnValueEncoder> GenericColumnWriter<'a, E> {
         max: Option<&E::T>,
         distinct_count: Option<u64>,
     ) -> Result<usize> {
+        // Check if number of definition levels is the same as number of repetition levels.

Review Comment:
   This check is moved from inside write_mini_batch as the slicing logic will panic if the lengths aren't consistent.
   
   Also as write_mini_batch is only called from this function, doing the check per mini batch was redundant



-- 
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-rs] tustvold commented on a diff in pull request #4327: Don't split record across pages (#3680)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #4327:
URL: https://github.com/apache/arrow-rs/pull/4327#discussion_r1212199518


##########
parquet/src/column/writer/mod.rs:
##########
@@ -569,6 +565,13 @@ impl<'a, E: ColumnValueEncoder> GenericColumnWriter<'a, E> {
                 )
             })?;
 
+            if !levels.is_empty() && levels[0] != 0 {
+                return Err(general_err!(
+                    "Write must start at a record boundary, got non-zero repetition level of {}",

Review Comment:
   This could be considered a breaking change, in that you are now prevented from writing an invalid parquet file. I'm not sure this counts



-- 
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-rs] tustvold merged pull request #4327: Don't split record across pages (#3680)

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


-- 
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-rs] alamb commented on pull request #4327: Don't split record across pages (#3680)

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

   BTW while poking around I found this line that does seem to imply that rows should not cross page boundaries:
   
   https://github.com/apache/parquet-format/blob/c766945d90935ebcd4e03fee13aad2b6efcadce3/src/main/thrift/parquet.thrift#L567


-- 
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-rs] tustvold commented on a diff in pull request #4327: Don't split record across pages (#3680)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #4327:
URL: https://github.com/apache/arrow-rs/pull/4327#discussion_r1213058826


##########
parquet/src/column/writer/mod.rs:
##########
@@ -308,6 +308,17 @@ impl<'a, E: ColumnValueEncoder> GenericColumnWriter<'a, E> {
         max: Option<&E::T>,
         distinct_count: Option<u64>,
     ) -> Result<usize> {
+        // Check if number of definition levels is the same as number of repetition levels.
+        if let (Some(def), Some(rep)) = (def_levels, rep_levels) {

Review Comment:
   There are already tests of this, they're actually how I realised that the slicing logic would panic :sweat_smile: 



-- 
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