[Fix](type) fix wrong type transform for unix_timestamp (#27728)
fix wrong type transform for unix_timestamp
This commit is contained in:
@ -1693,11 +1693,9 @@ public class FunctionCallExpr extends Expr {
|
||||
type.getScalarScale()));
|
||||
} else if (getChild(0).type.isStringType()) {
|
||||
// use DATETIME to make scale adaptive
|
||||
ScalarType type = ((ScalarType) (((StringLiteral) getChild(0))
|
||||
.uncheckedCastTo(ScalarType.DATETIME).type));
|
||||
ScalarType type = ((ScalarType) (getChild(0).uncheckedCastTo(ScalarType.DATETIME).type));
|
||||
if (type.isDatetimeV2()) {
|
||||
int scale = ((ScalarType) (((StringLiteral) getChild(0))
|
||||
.uncheckedCastTo(ScalarType.DATETIME).type)).getScalarScale();
|
||||
int scale = type.getScalarScale();
|
||||
fn.setReturnType(
|
||||
ScalarType.createDecimalType(PrimitiveType.DECIMAL64, 10 + scale, scale));
|
||||
}
|
||||
|
||||
@ -83,8 +83,8 @@ public class UnixTimestamp extends ScalarFunction
|
||||
* [['unix_timestamp'], 'INT', ['DATE'], 'DEPEND_ON_ARGUMENT'],
|
||||
* [['unix_timestamp'], 'DECIMAL64', ['DATETIMEV2'], 'DEPEND_ON_ARGUMENT'],
|
||||
* [['unix_timestamp'], 'INT', ['DATEV2'], 'DEPEND_ON_ARGUMENT'],
|
||||
* [['unix_timestamp'], 'INT', ['VARCHAR', 'VARCHAR'], 'ALWAYS_NULLABLE'],
|
||||
* [['unix_timestamp'], 'INT', ['STRING', 'STRING'], 'ALWAYS_NULLABLE'],
|
||||
* [['unix_timestamp'], 'DECIMAL64', ['VARCHAR', 'VARCHAR'], 'ALWAYS_NULLABLE'],
|
||||
* [['unix_timestamp'], 'DECIMAL64', ['STRING', 'STRING'], 'ALWAYS_NULLABLE'],
|
||||
*/
|
||||
@Override
|
||||
public boolean nullable() {
|
||||
|
||||
Reference in New Issue
Block a user