Skip to content

Fix crash on parquet column type mismatch - #68131

Merged
al13n321 merged 8 commits into
masterfrom
qast
Aug 16, 2024
Merged

al13n321 merged 8 commits into
masterfrom
qast

Conversation

@al13n321

@al13n321 al13n321 commented Aug 9, 2024 •

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Fixed crash in Parquet filtering when data types in the file substantially differ from requested types (e.g. ... FROM file('a.parquet', Parquet, 'x String'), but the file has x Int64). Without this fix, use input_format_parquet_filter_push_down = 0 as a workaround.

ParquetBlockInputFormat didn't cast Field-s to the requested types because I thought KeyCondition allows any types. I don't remember why I thought that. It was crashing in MergeTreeSetIndex::checkInRange() when FieldValue::update() tried to insert Field of wrong type into a column.

Fixes #68403

@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-bugfix Pull request with bugfix, not backported by default label Aug 9, 2024
@robot-clickhouse

robot-clickhouse commented Aug 9, 2024 •

Copy link
Copy Markdown
Member

This is an automated comment for commit 496a4c7 with description of existing statuses. It's updated for the latest CI running

✅ Click here to open a full report in a separate page

Successful checks
Check nameDescriptionStatus
AST fuzzerRuns randomly generated queries to catch program errors. The build type is optionally given in parenthesis. If it fails, ask a maintainer for help✅ success
Bugfix validationChecks that either a new test (functional or integration) or there some changed tests that fail with the binary built on master branch✅ success
BuildsThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
ClickBenchRuns [ClickBench](https://github.com/ClickHouse/ClickBench/) with instant-attach table✅ success
Compatibility checkChecks that clickhouse binary runs on distributions with old libc versions. If it fails, ask a maintainer for help✅ success
Docker keeper imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docker server imageThe check to build and optionally push the mentioned image to docker hub✅ success
Fast testNormally this is the first check that is ran for a PR. It builds ClickHouse and runs most of stateless functional tests, omitting some. If it fails, further checks are not started until it is fixed. Look at the report to see which tests fail, then reproduce the failure locally as described here✅ success
Flaky testsChecks if new added or modified tests are flaky by running them repeatedly, in parallel, with more randomization. Functional tests are run 100 times with address sanitizer, and additional randomization of thread scheduling. Integration tests are run up to 10 times. If at least once a new test has failed, or was too long, this check will be red. We don't allow flaky tests, read the doc✅ success
Install packagesChecks that the built packages are installable in a clear environment✅ success
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests✅ success
Performance ComparisonMeasure changes in query performance. The performance test report is described in detail here. In square brackets are the optional part/total tests✅ success
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Stateless testsRuns stateless functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors✅ success
Style checkRuns a set of checks to keep the code style clean. If some of tests failed, see the related log from the report✅ success
Unit testsRuns the unit tests for different release types✅ success
Upgrade checkRuns stress tests on server version from last release and then tries to upgrade it to the version from the PR. It checks if the new server can successfully startup without any errors, crashes or sanitizer asserts✅ success

@jkartseva jkartseva self-assigned this Aug 13, 2024

@jkartseva jkartseva left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@al13n321
al13n321 added this pull request to the merge queue Aug 16, 2024
Merged via the queue into master with commit dc4281c Aug 16, 2024
@al13n321
al13n321 deleted the qast branch August 16, 2024 04:20
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 16, 2024
baibaichen added a commit to Kyligence/gluten that referenced this pull request Aug 17, 2024
> Refer ClickHouse/ClickHouse#68494

(cherry picked from commit 9ec7071c3a0b00038989bdad0891842472d13098)
baibaichen added a commit to apache/gluten that referenced this pull request Aug 17, 2024
* [GLUTEN-1632][CH]Daily Update Clickhouse Version (20240817)

* Add ut for  ClickHouse/ClickHouse#68131

> Refer ClickHouse/ClickHouse#68494

(cherry picked from commit 9ec7071c3a0b00038989bdad0891842472d13098)

---------

Co-authored-by: kyligence-git <[email protected]>
Co-authored-by: Chang Chen <[email protected]>
/// may mean one of two things:
/// * The byte array is the 16 bytes of Int128, little-endian.
/// * The byte array is an ASCII string containing the Int128 formatted in base 10.
/// There's no reliable way to distinguish these cases. We just guess: if the

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgive the drive-by comment, but don't Parquet logical types provide the ability to make this distinction?

@al13n321 al13n321 Aug 23, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They don't support integers wider than 64 bits. From parquet.thrift:

/**
 * Integer logical type annotation
 *
 * bitWidth must be 8, 16, 32, or 64.
 *
 * Allowed for physical types: INT32, INT64
 */
struct IntType {
  1: required i8 bitWidth
  2: required bool isSigned
}

[...]

/**
 * Decimal logical type annotation
 *
 * To maintain forward-compatibility in v1, implementations using this logical
 * type must also set scale and precision on the annotated SchemaElement.
 *
 * Allowed for physical types: INT32, INT64, FIXED, and BINARY
 */
struct DecimalType {
  1: required i32 scale
  2: required i32 precision
}

[...]

union LogicalType {
  1:  StringType STRING       // use ConvertedType UTF8
  2:  MapType MAP             // use ConvertedType MAP
  3:  ListType LIST           // use ConvertedType LIST
  4:  EnumType ENUM           // use ConvertedType ENUM
  5:  DecimalType DECIMAL     // use ConvertedType DECIMAL + SchemaElement.{scale, precision}
  6:  DateType DATE           // use ConvertedType DATE

  // use ConvertedType TIME_MICROS for TIME(isAdjustedToUTC = *, unit = MICROS)
  // use ConvertedType TIME_MILLIS for TIME(isAdjustedToUTC = *, unit = MILLIS)
  7:  TimeType TIME

  // use ConvertedType TIMESTAMP_MICROS for TIMESTAMP(isAdjustedToUTC = *, unit = MICROS)
  // use ConvertedType TIMESTAMP_MILLIS for TIMESTAMP(isAdjustedToUTC = *, unit = MILLIS)
  8:  TimestampType TIMESTAMP

  // 9: reserved for INTERVAL
  10: IntType INTEGER         // use ConvertedType INT_* or UINT_*
  11: NullType UNKNOWN        // no compatible ConvertedType
  12: JsonType JSON           // use ConvertedType JSON
  13: BsonType BSON           // use ConvertedType BSON
  14: UUIDType UUID           // no compatible ConvertedType
}

(Maybe we could write them as DecimalType with scale = 0, Decimal supports arbitrary length. The precision parameter would be awkward. E.g. UInt256 can hold some but not all 78-digit numbers. We could use precision = 77 but allow the value to be greater than 10^77, but then other parquet decoders may consider this an error. We could use precision = 78 and 33-byte-long value, but then our decoder can't know in advance whether all values will fit in UInt256. The latter seems ok though, maybe that would be the best way to do this. Also, signedness would probably be awkward in some way too.)

robot-ch-test-poll1 added a commit that referenced this pull request Aug 23, 2024
Backport #68131 to 24.6: Fix crash on parquet column type mismatch
robot-ch-test-poll1 added a commit that referenced this pull request Aug 23, 2024
Backport #68131 to 24.7: Fix crash on parquet column type mismatch
robot-ch-test-poll1 added a commit that referenced this pull request Aug 23, 2024
Backport #68131 to 24.8: Fix crash on parquet column type mismatch
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-backports-created-cloud deprecated label, NOOP label Aug 23, 2024
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Aug 25, 2024
robot-ch-test-poll1 added a commit that referenced this pull request Aug 25, 2024
Backport #68131 to 24.5: Fix crash on parquet column type mismatch
al13n321 pushed a commit that referenced this pull request Aug 25, 2024
sharkdtu pushed a commit to sharkdtu/gluten that referenced this pull request Nov 11, 2024
)

* [GLUTEN-1632][CH]Daily Update Clickhouse Version (20240817)

* Add ut for  ClickHouse/ClickHouse#68131

> Refer ClickHouse/ClickHouse#68494

(cherry picked from commit 9ec7071c3a0b00038989bdad0891842472d13098)

---------

Co-authored-by: kyligence-git <[email protected]>
Co-authored-by: Chang Chen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-backports-created-cloud deprecated label, NOOP pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parquet query failed with In decimal column filter

8 participants