Skip to content

[CALCITE-6620] VALUES created by RelBuilder do not have a homogeneous type - #4000

Merged
mihaibudiu merged 1 commit into
apache:mainfrom
mihaibudiu:issue6620
Oct 10, 2024
Merged

[CALCITE-6620] VALUES created by RelBuilder do not have a homogeneous type#4000
mihaibudiu merged 1 commit into
apache:mainfrom
mihaibudiu:issue6620

Conversation

@mihaibudiu

Copy link
Copy Markdown
Contributor

The issue fixed here was first reported as part of https://issues.apache.org/jira/browse/CALCITE-6617

f0.forEachLibrary(libraries, consumer);
}

@Test void differentTypeValues() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this test belong here? It isn't testing an operator, or use the fixture.

Could it be a Quidem test?

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.

I will move it.
I don't know if I can create the same environment in Quidem. A simple attempt to reproduce this bug with standard settings failed.

RelDataType rowType, List<RexLiteral> values) {
assert values.size() == rowType.getFieldCount();
RexExecutor executor = cluster.getPlanner().getExecutor();
if (executor == null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we have a test for the executor == null?I'm not sure why this happened.

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.

Who knows who is calling the builder and with what setup?
This is just to be safe.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1, getExecutor is a nullable method.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we can improve it by RexExecutor rexImpl = Util.first(cluster.getPlanner().getExecutor(), RexUtil.EXECUTOR);

@mihaibudiu

Copy link
Copy Markdown
Contributor Author

Several quidem tests now have extra spaces in strings because they use a type system without raggedUnionTypesToVarying. The extra spaces are introduced when unifying the types of the VALUES. The new results seem the right ones.

RelDataType rowType, List<RexLiteral> values) {
assert values.size() == rowType.getFieldCount();
RexExecutor executor = cluster.getPlanner().getExecutor();
if (executor == null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1, getExecutor is a nullable method.

Comment thread core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml Outdated
Comment thread core/src/main/java/org/apache/calcite/tools/RelBuilder.java Outdated
List<RelDataTypeField> fields = rowType.getFieldList();
List<RexLiteral> constants = new ArrayList<>();
RexBuilder builder = cluster.getRexBuilder();
RexSimplify simplify = new RexSimplify(builder, RelOptPredicateList.EMPTY, executor);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Could the RexSimplify be passed as a parameter of this method? That would make the code simpler & cleaner, and we would avoid (re)creating a RexSimplify on each iteration that calls convertLiteralTypes.

… type

Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
@sonarqubecloud

sonarqubecloud Bot commented Oct 9, 2024

Copy link
Copy Markdown

@mihaibudiu
mihaibudiu merged commit 7ce986f into apache:main Oct 10, 2024
@mihaibudiu
mihaibudiu deleted the issue6620 branch October 10, 2024 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants