Skip to content

Commit

Permalink
Reverse the behavior when ANSI is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Nov 17, 2021
1 parent 0974f60 commit c8f71fb
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -538,11 +538,11 @@ class ColumnarCast(
new ArrowType.Int(64, true))
TreeBuilder.makeFunction("castINT", Lists.newArrayList(long_node), toType)
case _: StringType =>
// compatible with spark ANSI
// Compatible with spark ANSI
if (ansiEnabled) {
TreeBuilder.makeFunction("castINTOrNull", Lists.newArrayList(child_node0), toType)
} else {
TreeBuilder.makeFunction("castINT", Lists.newArrayList(child_node0), toType)
} else {
TreeBuilder.makeFunction("castINTOrNull", Lists.newArrayList(child_node0), toType)
}
case other =>
TreeBuilder.makeFunction("castINT", Lists.newArrayList(child_node0), toType)
Expand All @@ -558,11 +558,11 @@ class ColumnarCast(
toType),
TreeBuilder.makeLiteral(java.lang.Long.valueOf(1000L))), toType), toType)
case _: StringType =>
// compatible with spark ANSI
// Compatible with spark ANSI
if (ansiEnabled) {
(TreeBuilder.makeFunction("castBIGINTOrNull", Lists.newArrayList(child_node0), toType), toType)
} else {
(TreeBuilder.makeFunction("castBIGINT", Lists.newArrayList(child_node0), toType), toType)
} else {
(TreeBuilder.makeFunction("castBIGINTOrNull", Lists.newArrayList(child_node0), toType), toType)
}
case _ => (TreeBuilder.makeFunction("castBIGINT",
Lists.newArrayList(child_node0), toType), toType)
Expand All @@ -576,11 +576,11 @@ class ColumnarCast(
new ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE))
TreeBuilder.makeFunction("castFLOAT4", Lists.newArrayList(double_node), toType)
case _: StringType =>
// compatible with spark ANSI
// Compatible with spark ANSI
if (ansiEnabled) {
TreeBuilder.makeFunction("castFLOAT4OrNull", Lists.newArrayList(child_node0), toType)
} else {
TreeBuilder.makeFunction("castFLOAT4", Lists.newArrayList(child_node0), toType)
} else {
TreeBuilder.makeFunction("castFLOAT4OrNull", Lists.newArrayList(child_node0), toType)
}
case other =>
TreeBuilder.makeFunction("castFLOAT4", Lists.newArrayList(child_node0), toType)
Expand All @@ -589,10 +589,11 @@ class ColumnarCast(
} else if (dataType == DoubleType) {
val funcNode = child.dataType match {
case _: StringType =>
// Compatible with spark ANSI
if (ansiEnabled) {
TreeBuilder.makeFunction("castFLOAT8OrNull", Lists.newArrayList(child_node0), toType)
} else {
TreeBuilder.makeFunction("castFLOAT8", Lists.newArrayList(child_node0), toType)
} else {
TreeBuilder.makeFunction("castFLOAT8OrNull", Lists.newArrayList(child_node0), toType)
}
case other =>
TreeBuilder.makeFunction("castFLOAT8", Lists.newArrayList(child_node0), toType)
Expand Down

0 comments on commit c8f71fb

Please sign in to comment.