Repository navigation
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
/review |
|
Codex automated review failed and did not complete. Error: Review setup stopped before context preparation ran; inspect the first failed or cancelled setup step. Please inspect the workflow logs and rerun the review after the underlying issue is resolved. |
### Background A follower FE forwards CTAS to the master FE. The request contains user variables as Thrift literals, with a type descriptor and a string value. The master restores these variables before it analyzes the SQL and derives the CTAS column types. ### What problem does this PR solve? Issue Number: None Related PR: None PR Type: Bugfix Problem Summary: Forwarded date variables can lose their type or declared fractional scale. Midnight DATETIME and TIMESTAMPTZ values can become DATE, and a fractional part of .120000 can reduce scale 6 to scale 2. Losing TIMESTAMPTZ semantics can also remove matching rows or produce an eight-hour difference in a +08:00 session. Preserve the sender's type and scale so CTAS through a follower uses the same date values as direct master execution. ### Details - **Frequency:** Reproducible when a forwarded date variable has a declared type or scale that differs from the type inferred from its string. DATE can also switch between legacy and V2 types when the receiver's default date type differs from the sender's type. - **Root cause:** The literal decoder passed a null type to the date parser for every DATE_LITERAL except TIMESTAMP_NS. The parser then selected a type from the value and the receiver's date conversion setting. Separately, Type.fromThrift decoded TIMESTAMPTZ with default scale 0 instead of the declared scale. - **Why existing tests missed it:** Existing forwarding tests covered TIMESTAMP_NS. They did not check TIMESTAMPTZ type and scale, ordinary date type preservation, midnight DATETIME values, or fractional parts with trailing zeros. - **Fix:** Restore TIMESTAMPTZ scale from the existing type descriptor. Pass the decoded type to the literal parser for every DATE_LITERAL. Add type and literal round-trip tests and two small CTAS regressions. Update comments that described the old decoder behavior. - **Other paths and branches:** The shared type decoder also serves nested type descriptors and Java UDF types. Its TIMESTAMPTZ branch now retains scale. String type inference keeps its existing null-type path. TIMESTAMP_NS behavior and partition snapshot conversion logic are unchanged. No protocol fields, storage formats, or release branches are changed. - **Behavior change:** Forwarded DATE and DATETIME variables retain their type and declared scale. TIMESTAMPTZ variables also retain their UTC value and time zone semantics. DATE type preservation is separate from the existing CTAS column conversion rules. ### Testing - Local FE build and Checkstyle passed with `FE_MAVEN_THREADS=8 DISABLE_BE_JAVA_EXTENSIONS=ON bash build.sh --fe`. - The type decoder test run passed 57 tests: `bash run-fe-ut.sh --run org.apache.doris.qe.ConnectProcessorTimestampTzTest,org.apache.doris.qe.ConnectProcessorTimestampNsTest,org.apache.doris.analysis.DateLiteralUtilsTest,org.apache.doris.catalog.TypeTest`. - The final source passed 56 tests: `bash run-fe-ut.sh --run org.apache.doris.qe.ConnectProcessorDateLiteralTest,org.apache.doris.qe.ConnectProcessorTimestampNsTest,org.apache.doris.qe.ConnectProcessorTimestampTzTest,org.apache.doris.analysis.DateLiteralUtilsTest`. This includes all 20 ordinary date cases. Neither unit test run had failures, errors, or skipped tests. - Failure checks confirmed that all four TIMESTAMPTZ cases failed before its type and scale fix. Sixteen of the 20 ordinary date cases failed before those types were preserved. The ordinary date SQL regression also failed through a follower before the fix, with DATE, DATETIME(0), and DATETIME(2) columns where DATETIME(6) was required. - Both SQL suites passed through both FE roles in a local two-FE, one-BE cluster: `bash run-regression-test.sh --run -d datatype_p0/datetimev2,datatype_p0/timestamptz -s test_date_user_variable_ctas,test_timestamptz_user_variable_ctas`, with the connection configuration set for each entry point. A follower connection is required to test forwarding. - The ordinary date SQL test needs no source table and creates one result row. The TIMESTAMPTZ test uses one source row to check equality filtering, column type, scale, displayed value, and zero hour difference. Expected output files were generated by the regression script. - Legacy DATE versus DATEV2 changes under both enable_date_conversion settings are covered by unit tests. The SQL DATE column is a control case under the default configuration. ### Release note Fix CTAS through a follower FE when it uses date user variables. Midnight DATETIME values keep their time type, and fractional precision is preserved. TIMESTAMPTZ variables retain their time zone semantics, so matching rows and time differences agree with direct master execution. ### Check List (For Author) - Behavior changed: Yes (see Details) - Does this need documentation: No - Pre-submission status: Ready ### AI Disclosure - Tool: Codex - Generated: Code, comments, tests, and this description - Human review: Pending
7c8bde3 to
41a78cc
Compare
|
/review |
|
run buildall |
There was a problem hiding this comment.
No substantiated new findings in the complete static review of PR #70380 at 41a78cc. Reviewed all 11 changed files and related producer/consumer paths. The two complete-scope reviewers and dedicated risk reviewer all returned NO_NEW_VALUABLE_FINDINGS; the main review independently verified their evidence. Converged after round 1. No existing inline findings or independently confirmed existing P0/P1 blockers.
Traced SET user variable -> legacy literal -> FEOpExecutor serialization -> forwarded request -> ConnectProcessor reconstruction -> Nereids literal conversion -> CTAS analysis and insertion. The declared temporal type and scale now survive decoding, and typed TIMESTAMPTZ parsing preserves the sender's UTC instant.
Critical checkpoint conclusions:
- Goal and proof: The fix addresses TIMESTAMPTZ type/scale loss and midnight/trailing-zero inference for other dates. Type and decoder unit tests plus CTAS regressions target these behaviors; their code and expectations were inspected.
- Scope and reuse: Two small production behavior changes reuse existing type factories and literal parsing. The other two production edits only correct comments.
- Concurrency and locks: Reconstruction remains synchronous with per-request maps/literals; no new shared state, thread, lock acquisition, heavy work under metadata locks, or lock-order change.
- Lifecycle and initialization: No new resource ownership, cleanup path, asynchronous lifetime, or static initialization dependency. Test configuration/thread-local changes have finally cleanup.
- Configuration: No configuration items added. Date decoder tests cover both receiver enable_date_conversion settings.
- Compatibility: Existing descriptor fields and wire formats are retained. Both HEAD and merge-base ScalarType serializers emit TIMESTAMPTZ precision and scale; reachable UDF wrappers preserve those descriptors. No concrete new missing-field failure found.
- Thrift/protobuf definitions: No gensrc changes or field/enum ID changes.
- Parallel paths: Checked DATE, DATEV2, DATETIME, DATETIMEV2, TIMESTAMPTZ, unchanged TIMESTAMP_NS, nested ARRAY/MAP/STRUCT decoding, Java UDF descriptors, and partition schema freezing. The common forwarding decoder covers redirected commands and forwarded queries.
- Conditions and invariants: Valid sender strings satisfy the typed parser branches. TIMESTAMPTZ strings include +00:00 and select UTC during restoration, including before thread-local context installation. New field preconditions match actual producers and adjacent temporal decoding.
- Test coverage: New tests cover temporal families, midnight/noon, scales 0/3/6, zero and trailing-zero fractions, +08 session interpretation, CTAS filtering and projection. Existing parser tests cover invalid inputs, offsets, boundaries and nanoseconds. No new malformed-input behavior requiring a separate negative test was identified.
- Changed expected results: Both .out files agree with the SQL and inspected formatting paths, including datetime(6), timestamp(6), bigint(20), +08 rendering and zero-hour difference. Results are deterministically ordered; tables are dropped before use and retained afterward.
- Observability: Existing parser/RPC errors remain adequate for this local deterministic conversion; no new operational path requires logs or metrics.
- Transactions and persistence: No EditLog, replay, failover or transaction protocol changes.
- Writes and atomicity: CTAS execution mechanics remain unchanged; the corrected literal feeds analysis and insertion. Storage visible-version, delete-bitmap and crash-cleanup logic are unchanged.
- FE/BE variables: No new transmitted variable or serialization field; precision and scale use existing descriptors.
- Performance and memory: The scalar decoder adds constant work, retaining existing recursive traversal and short-string parsing complexity. No new IO, retained resource or significant allocation mechanism.
- Other issues: Final sweep and independent missed-case rechecks found no additional substantiated issue. Both initial risks were dismissed with concrete evidence; no unresolved candidate or uncovered static-review scope remains.
No additional user-provided focus was supplied. Validation limits: this invocation performed static inspection only, with no builds, tests, benchmarks or runtime validation. The SQL suites exercise forwarding when invoked through a follower FE; their configured connection does not itself guarantee that topology. Execution and generated-output provenance were not independently verified, and author-reported test runs are not claimed as reviewer-executed evidence.
Review converged after 1 round(s).
### Background Changelog windows use TSO timestamps. A background scheduler updates TSO physical time independently of SQL NOW(). Auto partition retention also runs in the background, while the aggregate cache test loads its initial count. ### What problem does this PR solve? Issue Number: None Related PR: None PR Type: Test Problem Summary: Two regression tests can fail because their setup does not control these background tasks. A changelog window can exclude the first update and return 11 instead of 10. Partition retention can remove three rows before the test checks its initial count of six. Wait for a TSO boundary and delay the lower retention limit until the initial cached count has been checked. ### Details - **Failure:** test_changelog_before_column_name can fail at value_min_delta with [1, 1, 11, 101] instead of [1, 1, 10, 100]. auto_partition_recycle_count_cache can report 3 instead of 6 before its intended recycle phase. - **Cause:** The changelog test derives its boundary from NOW(), but subsequent transaction TSO values can still be below that boundary. The cache test enables retention_count=3 at table creation, so normal scheduler activity can remove partitions during cache loading. - **Stability evidence:** Both original errors were reproduced with controlled timing. A TSO offset of -2000 ms excluded the first update; a one-second scheduler interval and a delay before the baseline query allowed early recycling. Both complete suites passed with the same conditions after the changes. The normal suites then passed three consecutive runs each. The changelog helper now selects the next whole second after the current TSO and waits until TSO reaches it. FE formatting preserves the session time zone. All three windows in that suite use the helper. The cache test retains all six partitions until it checks the cached count, then sets retention_count=3. Fixed count results use script-generated output, and the table remains available after the test for inspection. Production code and test data are unchanged. ### Testing - Controlled reproduction before the changes: both suites failed with the reported values. Controlled validation after the changes: both complete suites passed, with no skipped scripts. - Normal regression: `JDK_17=/mnt/disk2/tengjianping/local/jdk-17.0.2 bash run-regression-test.sh --run -d changelog_p0,nereids_rules_p0/rewrite_simple_agg_to_constant -s test_changelog_before_column_name,auto_partition_recycle_count_cache -times 3`. All six suite executions passed. - Generated the new count output with `run-regression-test.sh --run -d nereids_rules_p0/rewrite_simple_agg_to_constant -s auto_partition_recycle_count_cache -genOut`. The changelog expected output is unchanged. - Validation used an isolated local FE and ASAN BE from the current worktree. No production source was changed or rebuilt. Cloud mode was not run. - Confirmed that the scheduler interval was restored and the local TSO test offset was cleared. ### Release note None ### Check List (For Author) - Behavior changed: No - Does this need documentation: No - Pre-submission status: Ready ### AI Disclosure - Tool: Codex - Generated: Test changes, comments, and this description - Human review: Pending
0354ae1 to
8523e19
Compare
|
run buildall |
|
/review |
There was a problem hiding this comment.
Static review of all 14 changed paths at 8523e19 found no actionable new issues. No existing inline findings were present to carry forward.
The reviewed flow is: follower user variable -> FEOpExecutor/ExprToThriftVisitor (declared type and canonical text) -> ConnectProcessor -> DateLiteralUtils -> ConnectContext/Literal.fromLegacyLiteral -> master CTAS analysis. Preserving TIMESTAMPTZ type and scale keeps the canonical UTC fields intact and prevents midnight values from being inferred as DATE.
Critical checkpoint conclusions:
- Goal and proof: the two production changes preserve the sender's temporal type and fractional scale. New type/literal round-trip tests and CTAS suites cover the intended failures; these tests were inspected, not executed in this review.
- Scope and reuse: the fix reuses the existing parser and scalar-type factory. Two comment updates are accurate. The additional changelog and partition-cache test changes are separate stability fixes and were also reviewed.
- Concurrency and locks: no new production thread, shared state, metadata-lock acquisition, lock ordering, or IO under a lock is introduced. Test polling reuses the master TSO snapshot lock and existing scheduler behavior.
- Lifecycle and initialization: restored literals remain request-local; no new resource ownership, callback lifetime, reference cycle, or static initialization dependency is introduced. Tests restore the global date-conversion setting/scheduler interval and remove their thread-local context in finally blocks.
- Configuration: no new setting is added. Explicit sender types correctly avoid dependence on the receiver's enable_date_conversion default.
- Compatibility: no function symbol or storage/wire layout changes. The pre-fix FE serializer already writes both TIMESTAMPTZ precision and scale. Production Java UDF transport preserves FE descriptors; recursive array/map/struct decoding reaches the same corrected scalar branch. This does not add TIMESTAMPTZ Java UDF support.
- Thrift/Protobuf definitions: no gensrc files, field IDs, enum values, or field optionality change.
- Parallel paths: DATE, DATEV2, DATETIME, DATETIMEV2, TIMESTAMPTZ, and TIMESTAMP_NS producer/parser/consumer paths were checked. TIMESTAMP_NS already received its explicit type and remains unchanged. The partition snapshot still retains all scalar parameters.
- Conditions and error handling: canonical sender formats satisfy explicit parser shape and fractional limits. TIMESTAMPTZ text always carries +00:00, making restoration independent of when the receiver binds its context. Existing parse exceptions and descriptor invariant failures remain appropriate; zero-month/day rejection predates this PR.
- Test coverage: new cases cover midnight/noon, zero and nonzero fractions, trailing zeros, scales 0/3/6, both date-conversion defaults, a non-UTC receiver session, filtering, CTAS column types, and timestampdiff. Existing parser negatives, timezone/DST tests, and nanosecond forwarding coverage remain. The CTAS suites exercise actual forwarding when run through a follower; they do not create that topology themselves.
- Expected results: all three new output files match their SQL. UTC midnight renders as 08:00 at +08:00 with zero hour difference; date CTAS retains DATETIME(6); partition counts are 6 before recycling and 3 afterward. Changelog boundaries query the master's TSO, round strictly past prior writes, and wait before subsequent writes; inclusive start semantics preserve those later writes.
- Observability: existing parser/request errors and bounded polling failures provide adequate diagnostics for this correction; no new metrics or logging requirement identified.
- Transactions, persistence, and failover: production journal/replay and transaction state are unchanged. Partition-drop and replay cache invalidation were traced for the regression test.
- Data writes and atomicity: CTAS and regression DML use existing write paths; the fix only changes reconstructed literals. No new write atomicity, crash-cleanup, or lock-lifetime issue identified.
- FE/BE variable passing: no new transmitted variable; existing type descriptor fields are reused across forwarding and function metadata.
- Performance: descriptor reconstruction remains bounded per scalar, with existing recursion for compound types; no new hot-path IO or asymptotic work. Changelog waits are bounded. Changing retention from 6 to 3 preserves the warmed count cache until partition removal, so the cache regression still exercises its intended invalidation path.
- Additional risk review: both explicit-type parsing and shared descriptor field requirements were independently challenged and dismissed with producer/consumer evidence. No unresolved candidate or uncovered changed path remains.
User focus: no additional focus points were supplied. Validation limits: static inspection only; no builds, tests, benchmarks, or live mixed-version/two-FE validation were performed by this review.
Review converged after 2 round(s).
|
run external |
Background
A follower FE forwards CTAS to the master FE. The request includes user variables as typed Thrift literals. The master restores these variables before it analyzes the statement.
What problem does this PR solve?
Issue Number: None
Related PR: None
PR Type: Bugfix
Problem Summary:
Forwarded TIMESTAMPTZ user variables can become DATE or DATETIME values. CTAS can then omit matching rows, create the wrong column type, or return an incorrect time difference. Restore both the declared type and its scale during decoding.
Details
Testing
bash run-fe-ut.sh --run org.apache.doris.qe.ConnectProcessorTimestampTzTest,org.apache.doris.qe.ConnectProcessorTimestampNsTest,org.apache.doris.analysis.DateLiteralUtilsTest,org.apache.doris.catalog.TypeTest.FE_MAVEN_THREADS=8 DISABLE_BE_JAVA_EXTENSIONS=ON bash build.sh --fe.bash run-regression-test.sh --run -d datatype_p0/timestamptz -s test_timestamptz_user_variable_ctasthrough both FE roles. Both passed with the final build in an isolated two-FE, one-BE cluster.git -c core.whitespace=-blank-at-eof diff --cached --checkpassed. The generated regression output retains its standard final blank line.Release note
Fix CTAS results when a follower FE forwards TIMESTAMPTZ user variables. Matching rows, time differences, column types, and fractional precision now agree with direct master execution.
Check List (For Author)
AI Disclosure
Background
What problem does this PR solve?
Issue Number:
Related PR:
PR Type:
Problem Summary:
Details
Testing
Notes for Reviewers
Release note
Check List (For Author)
AI Disclosure