Skip to content

Commit

Permalink
add uts for element_at
Browse files Browse the repository at this point in the history
  • Loading branch information
taiyang-li committed Dec 5, 2023
1 parent feaa8a4 commit 7983ca2
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -485,4 +485,31 @@ class GlutenFunctionValidateSuite extends GlutenClickHouseWholeStageTransformerS
"select * from date_table where to_date(from_unixtime(ts)) = '2019-01-01'",
noFallBack = true) { _ => }
}

test("test element_at function") {
withSQLConf(
SQLConf.OPTIMIZER_EXCLUDED_RULES.key ->
(ConstantFolding.ruleName + "," + NullPropagation.ruleName)) {
// input type is array<array<int>>
runQueryAndCompare(
"SELECT array(array(1,2,3), array(4,5,6))[1], " +
"array(array(id,id+1,id+2), array(id+3,id+4,id+5)) from range(100)",
noFallBack = false
)(checkOperatorMatch[ProjectExecTransformer])

// input type is array<array<string>>
runQueryAndCompare(
"SELECT array(array('1','2','3'), array('4','5','6'))[1], " +
"array(array('1','2',cast(id as string)), array('4','5',cast(id as string)))[1] " +
"from range(100)",
noFallBack = false
)(checkOperatorMatch[ProjectExecTransformer])

// input type is array<map<string, int>>
runQueryAndCompare(
"SELECT array(map(cast(id as string), id), map(cast(id+1 as string), id+1))[1] " +
"from range(100)" noFallBack = false
)(checkOperatorMatch[ProjectExecTransformer])
}
}
}

0 comments on commit 7983ca2

Please sign in to comment.