Skip to content

HIVE-28667: Error initializing field trimmer instance when starting HS2 #5879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2025

Conversation

zabetak
Copy link
Member

@zabetak zabetak commented Jun 17, 2025

What changes were proposed in this pull request?

  1. Change trimFields(JdbcRel) to trimFields(JdbcSort) to break the ambiguity and avoid the error.
  2. Make CalcitePlanner#HIVE_REL_NODE_CLASSES public mainly to facilitate testing. In fact, it makes sense to expose this information somewhere so why not in CalcitePlanner.

Why are the changes needed?

Avoid the ambiguity exception during HS2 startup. For more details see commit message or HIVE-28667.

Does this PR introduce any user-facing change?

No. There is no change in behavior since anyways the trimmer cannot be called with a JdbcSort operator.

How was this patch tested?

mvn test -Dtest=TestHiveRelFieldTrimmer -pl ql
mvn test -Dtest=TestMiniLlapLocalCliDriver -Dqfile_regex=".*jdbc.*" -pl itests/qtest -Pitests

RelFieldTrimmer class is a reflection based visitor that tries to find the appropriate method based on the type (Class) of the argument. The errors occurs while trying to register a method dispatcher for `JdbcSort.class` since there are multiple candidate methods that qualify:
* trimFields(JdbcRel rel, ImmutableBitSet fieldsUsed, Set<RelDataTypeField> extraFields)
* trimFields(Sort sort, ImmutableBitSet fieldsUsed, Set<RelDataTypeField> extraFields)
Given that there is no inheritance relationship between `Sort` and `JdbcRel` it is unclear which method should be used to handle JdbcSort leading to an exception that informs the user/dev about the ambiguous semantics.

It seems that the intention of adding trimFields(JdbcRel...) method was to have a fallback for Jdbc operators that are not handled explicitly by the trimmer but this can never work and creates ambiguity as explained above.
The reason that we get this error only during startup of HS2 and not during compilation is because in the current code it is impossible to call the RelFieldTrimmer code with Jdbc operators other than HiveJdbcConverter and JdbcHiveTableScan.

1. Change trimFields(JdbcRel) to trimFields(JdbcSort) to break the ambiguity and avoid the error. There is no change in behavior since anyways the trimmer cannot be called with a JdbcSort operator.
2. Make CalcitePlanner#HIVE_REL_NODE_CLASSES public mainly to facilitate testing. In fact, it makes sense to expose this information somewhere so why not in CalcitePlanner.
@ngsg
Copy link
Contributor

ngsg commented Jun 26, 2025

The patch looks good to me, +1(non-biding).

Copy link
Contributor

@okumin okumin left a comment

Choose a reason for hiding this comment

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

+1

I verified that the error message is still displayed with the master branch, and it is never shown with this patch.

Copy link

@zabetak zabetak merged commit 3e6f2c7 into apache:master Jun 30, 2025
6 checks passed
@zabetak zabetak deleted the HIVE-28667 branch June 30, 2025 08:43
@zabetak
Copy link
Member Author

zabetak commented Jun 30, 2025

Many thanks for the reviews @ngsg @okumin !

zhangbutao added a commit to zhangbutao/hive that referenced this pull request Jul 1, 2025
zhangbutao pushed a commit to zhangbutao/hive that referenced this pull request Jul 1, 2025
zhangbutao added a commit that referenced this pull request Jul 2, 2025
…S2 (#5879) (#5913)

Co-authored-by: Stamatis Zampetakis <zabetak@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants