Skip to content
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

[CALCITE-6380] Casts from INTERVAL and STRING to DECIMAL are incorrect #3790

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mihaibudiu
Copy link
Contributor

No description provided.

Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
Copy link
Member

@caicancai caicancai left a comment

Choose a reason for hiding this comment

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

Overall LGTM

@@ -770,41 +773,39 @@ void testCastIntervalToNumeric(CastType castType, SqlOperatorFixture f) {
f.setFor(SqlStdOperatorTable.CAST, VmName.EXPAND);

// interval to decimal
Copy link
Member

Choose a reason for hiding this comment

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

Interval to Decimal

Expressions.constant(scale),
Expressions.constant(sourceType.getSqlTypeName().getEndUnit().multiplier));
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Should we throw an exception when a situation does not include the above three cases

// string to decimal
f.checkScalarExact("cast('1.29' as decimal(2,1))",
"DECIMAL(2, 1) NOT NULL",
"1.3");
"1.2");
Copy link
Contributor

@YiwenWu YiwenWu May 22, 2024

Choose a reason for hiding this comment

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

Different systems have different interception methods, I think the return value 1.3 is also reasonable. Most systems return 1.3, such as MySQL, PostgreSQL, Hive, and Spark, but ClickHouse returns 1.2.

Copy link
Member

Choose a reason for hiding this comment

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

There doesn't seem to be a standard set of sql rules here, so maybe we should think about what makes sense mathematically or what makes sense to follow the rules of most databases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants