Skip to content

Commit

Permalink
allow to use differnent case in SQL
Browse files Browse the repository at this point in the history
Signed-off-by: Yuan Zhou <[email protected]>
  • Loading branch information
zhouyuan committed Sep 5, 2022
1 parent 918f2d6 commit f5f5aab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ object ColumnarExpressionConverter extends Logging {
val b = bindReference.asInstanceOf[BoundReference]
new ColumnarBoundReference(b.ordinal, b.dataType, b.nullable)
} else {
return new ColumnarAttributeReference(a.name, a.dataType, a.nullable, a.metadata)(
return new ColumnarAttributeReference(a.name.toLowerCase, a.dataType, a.nullable, a.metadata)(
a.exprId,
a.qualifier)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,7 @@ class ColumnarHashAggregation(
}

val originalInputFieldList = originalInputAttributes.toList.map(attr => {
Field
.nullable(s"${attr.name}#${attr.exprId.id}", CodeGeneration.getResultType(attr.dataType))
ConverterUtils.createArrowField(attr)
})

//////////////// Project original input to aggregateExpression input //////////////////
Expand Down Expand Up @@ -501,7 +500,7 @@ class ColumnarHashAggregation(
val inputAttrs = originalInputAttributes.zipWithIndex
.filter {
case (attr, i) =>
!groupingAttributes.contains(attr) && !partialProjectOrdinalList.toList.contains(i)
!groupingAttributes.contains(attr.withName(attr.name.toLowerCase)) && !partialProjectOrdinalList.toList.contains(i)
}
.map(_._1)
inputAttrQueue = scala.collection.mutable.Queue(inputAttrs: _*)
Expand All @@ -516,10 +515,7 @@ class ColumnarHashAggregation(

val aggregateAttributeFieldList =
allAggregateResultAttributes.map(attr => {
Field
.nullable(
s"${attr.name}#${attr.exprId.id}",
CodeGeneration.getResultType(attr.dataType))
ConverterUtils.createArrowField(attr)
})

val nativeFuncNodes = groupingNativeFuncNodes ::: aggrNativeFuncNodes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ object ConverterUtils extends Logging {
case a: AggregateExpression =>
getAttrFromExpr(a.aggregateFunction.children(0))
case a: AttributeReference =>
a
a.withName(a.name.toLowerCase)
case a: Alias =>
if (skipAlias) {
if (a.child.isInstanceOf[AttributeReference] || a.child.isInstanceOf[Coalesce]) {
Expand Down Expand Up @@ -483,8 +483,7 @@ object ConverterUtils extends Logging {

def toArrowSchema(attributes: Seq[Attribute]): Schema = {
val fields = attributes.map(attr => {
Field
.nullable(s"${attr.name}#${attr.exprId.id}", CodeGeneration.getResultType(attr.dataType))
createArrowField(attr)
})
new Schema(fields.toList.asJava)
}
Expand Down Expand Up @@ -618,7 +617,7 @@ object ConverterUtils extends Logging {
}

def createArrowField(attr: Attribute): Field =
createArrowField(s"${attr.name}#${attr.exprId.id}", attr.dataType)
createArrowField(s"${attr.name.toLowerCase}#${attr.exprId.id}", attr.dataType)

private def asTimestampType(inType: ArrowType): ArrowType.Timestamp = {
if (inType.getTypeID != ArrowTypeID.Timestamp) {
Expand Down

0 comments on commit f5f5aab

Please sign in to comment.