-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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-6684] Arrow adapter should supports filter conditions of Decimal type #4043
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,7 +194,7 @@ private String translateBinary(String op, String rop, RexCall call) { | |
private String translateOp2(String op, String name, RexLiteral right) { | ||
Object value = literalValue(right); | ||
String valueString = value.toString(); | ||
String valueType = getLiteralType(value); | ||
String valueType = getLiteralType(value, right.getType()); | ||
|
||
if (value instanceof String) { | ||
final RelDataTypeField field = requireNonNull(rowType.getField(name, true, false), "field"); | ||
|
@@ -234,8 +234,10 @@ private String translateUnaryOp(String op, String name) { | |
return name + " " + op; | ||
} | ||
|
||
private static String getLiteralType(Object literal) { | ||
if (literal instanceof BigDecimal) { | ||
private static String getLiteralType(Object literal, RelDataType type) { | ||
if (type.getSqlTypeName() == SqlTypeName.DECIMAL) { | ||
return "decimal"; | ||
} else if (literal instanceof BigDecimal) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since now you are passing type information to this function you should use it everywhere. There is no reason to guess the type based on the Java type of the literal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
BigDecimal bigDecimalLiteral = (BigDecimal) literal; | ||
int scale = bigDecimalLiteral.scale(); | ||
if (scale == 0) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comply with Calcite's default Decimal type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use the type system to retrieve the default type, assuming it is available here.
Maybe there is a default type for Arrow, but the "default" type for Calcite is irrelevant in this context.