Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -980,14 +980,8 @@ protected T getXpathOrFuncExprNodeDesc(ASTNode node,

final PrimitiveTypeInfo colTypeInfo = TypeInfoFactory.getPrimitiveTypeInfo(
exprFactory.getTypeInfo(columnChild).getTypeName().toLowerCase());
T newChild = interpretNodeAsConstant(colTypeInfo, constChild,
exprFactory.isEqualFunction(fi));
if (newChild == null) {
// non-interpretable as target type...
if (!exprFactory.isNSCompareFunction(fi)) {
return exprFactory.createBooleanConstantExpr(null);
}
} else {
T newChild = interpretNodeAsConstant(colTypeInfo, constChild);
if (newChild != null) {
children.set(constIdx, newChild);
}
}
Expand All @@ -1007,17 +1001,12 @@ protected T getXpathOrFuncExprNodeDesc(ASTNode node,
T columnDesc = children.get(0);
T valueDesc = interpretNode(columnDesc, children.get(i));
if (valueDesc == null) {
if (hasNullValue) {
// Skip if null value has already been added
continue;
}
TypeInfo targetType = exprFactory.getTypeInfo(columnDesc);
// Keep original
TypeInfo targetType = exprFactory.getTypeInfo(children.get(i));
if (!expressions.containsKey(targetType)) {
expressions.put(targetType, columnDesc);
}
T nullConst = exprFactory.createConstantExpr(targetType, null);
expressions.put(targetType, nullConst);
hasNullValue = true;
expressions.put(targetType, children.get(i));
} else {
TypeInfo targetType = exprFactory.getTypeInfo(valueDesc);
if (!expressions.containsKey(targetType)) {
Expand Down
14 changes: 14 additions & 0 deletions ql/src/test/queries/clientpositive/in_coercion.q
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
DROP TABLE src_table;
CREATE TABLE src_table (key int);
LOAD DATA LOCAL INPATH '../../data/files/kv6.txt' INTO TABLE src_table;

-- verify table has data
select count(*) from src_table;
-- should coerce key (int) and 355.8 to be comparable types
select count(*) from src_table where key in (355.8);
-- should coerce key (int) and 1.0 to be comparable types, but 1 exists in the table
select count(*) from src_table where key in (1.0, 0.0);
-- should coerce key (int) and 355.8 to be comparable types
select count(*) from src_table where key not in (355.8);
-- should coerce key (int) and 1.0 to be comparable types, but 1 exists in the table
select count(*) from src_table where key not in (1.0, 0.0);
65 changes: 65 additions & 0 deletions ql/src/test/results/clientpositive/llap/in_coercion.q.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
PREHOOK: query: DROP TABLE src_table
PREHOOK: type: DROPTABLE
POSTHOOK: query: DROP TABLE src_table
POSTHOOK: type: DROPTABLE
PREHOOK: query: CREATE TABLE src_table (key int)
PREHOOK: type: CREATETABLE
PREHOOK: Output: database:default
PREHOOK: Output: default@src_table
POSTHOOK: query: CREATE TABLE src_table (key int)
POSTHOOK: type: CREATETABLE
POSTHOOK: Output: database:default
POSTHOOK: Output: default@src_table
PREHOOK: query: LOAD DATA LOCAL INPATH '../../data/files/kv6.txt' INTO TABLE src_table
PREHOOK: type: LOAD
#### A masked pattern was here ####
PREHOOK: Output: default@src_table
POSTHOOK: query: LOAD DATA LOCAL INPATH '../../data/files/kv6.txt' INTO TABLE src_table
POSTHOOK: type: LOAD
#### A masked pattern was here ####
POSTHOOK: Output: default@src_table
PREHOOK: query: select count(*) from src_table
PREHOOK: type: QUERY
PREHOOK: Input: default@src_table
#### A masked pattern was here ####
POSTHOOK: query: select count(*) from src_table
POSTHOOK: type: QUERY
POSTHOOK: Input: default@src_table
#### A masked pattern was here ####
100
PREHOOK: query: select count(*) from src_table where key in (355.8)
PREHOOK: type: QUERY
PREHOOK: Input: default@src_table
#### A masked pattern was here ####
POSTHOOK: query: select count(*) from src_table where key in (355.8)
POSTHOOK: type: QUERY
POSTHOOK: Input: default@src_table
#### A masked pattern was here ####
0
PREHOOK: query: select count(*) from src_table where key in (1.0, 0.0)
PREHOOK: type: QUERY
PREHOOK: Input: default@src_table
#### A masked pattern was here ####
POSTHOOK: query: select count(*) from src_table where key in (1.0, 0.0)
POSTHOOK: type: QUERY
POSTHOOK: Input: default@src_table
#### A masked pattern was here ####
100
PREHOOK: query: select count(*) from src_table where key not in (355.8)
PREHOOK: type: QUERY
PREHOOK: Input: default@src_table
#### A masked pattern was here ####
POSTHOOK: query: select count(*) from src_table where key not in (355.8)
POSTHOOK: type: QUERY
POSTHOOK: Input: default@src_table
#### A masked pattern was here ####
100
PREHOOK: query: select count(*) from src_table where key not in (1.0, 0.0)
PREHOOK: type: QUERY
PREHOOK: Input: default@src_table
#### A masked pattern was here ####
POSTHOOK: query: select count(*) from src_table where key not in (1.0, 0.0)
POSTHOOK: type: QUERY
POSTHOOK: Input: default@src_table
#### A masked pattern was here ####
0