Skip to content
Merged
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 @@ -155,25 +155,25 @@ public void testQueries(boolean useMultiStageQueryEngine)
{MET_DOUBLE_SORTED + " < 0.05", "5"},
// TODO: Fix the issue with float data type
// {MET_FLOAT_SORTED + " > 0.05", "4"},
// {MET_FLOAT_SORTED + " = 0.05", "1"},
{MET_FLOAT_SORTED + " = 0.05", "1"},
// {MET_FLOAT_SORTED + " < 0.05", "5"},
{MET_DOUBLE_UNSORTED + " > 0.05", "4"},
{MET_DOUBLE_UNSORTED + " = 0.05", "1"},
{MET_DOUBLE_UNSORTED + " < 0.05", "5"},
// {MET_FLOAT_UNSORTED + " > 0.05", "4"},
// {MET_FLOAT_UNSORTED + " = 0.05", "1"},
{MET_FLOAT_UNSORTED + " = 0.05", "1"},
// {MET_FLOAT_UNSORTED + " < 0.05", "5"},
{MET_DOUBLE_SORTED_NO_DIC + " > 0.05", "4"},
{MET_DOUBLE_SORTED_NO_DIC + " = 0.05", "1"},
{MET_DOUBLE_SORTED_NO_DIC + " < 0.05", "5"},
// {MET_FLOAT_SORTED_NO_DIC + " > 0.05", "4"},
// {MET_FLOAT_SORTED_NO_DIC + " = 0.05", "1"},
{MET_FLOAT_SORTED_NO_DIC + " = 0.05", "1"},
// {MET_FLOAT_SORTED_NO_DIC + " < 0.05", "5"},
{MET_DOUBLE_UNSORTED_NO_DIC + " > 0.05", "4"},
{MET_DOUBLE_UNSORTED_NO_DIC + " = 0.05", "1"},
{MET_DOUBLE_UNSORTED_NO_DIC + " < 0.05", "5"},
// {MET_FLOAT_UNSORTED_NO_DIC + " > 0.05", "4"},
// {MET_FLOAT_UNSORTED_NO_DIC + " = 0.05", "1"},
{MET_FLOAT_UNSORTED_NO_DIC + " = 0.05", "1"},
// {MET_FLOAT_UNSORTED_NO_DIC + " < 0.05", "5"},
};
for (String[] faec : filterAndExpectedCount) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,19 @@ private RelDataType toRelDataType(FieldSpec fieldSpec) {
case LONG:
return fieldSpec.isSingleValueField() ? createSqlType(SqlTypeName.BIGINT)
: createArrayType(createSqlType(SqlTypeName.BIGINT), -1);
// Map float and double to the same RelDataType so that queries like
// `select count(*) from table where aFloatColumn = 0.05` works correctly in multi-stage query engine.
//
// If float and double are mapped to different RelDataType,
// `select count(*) from table where aFloatColumn = 0.05` will be converted to
// `select count(*) from table where CAST(aFloatColumn as "DOUBLE") = 0.05`. While casting
// from float to double does not always produce the same double value as the original float value, this leads to
// wrong query result.
//
// With float and double mapped to the same RelDataType, the behavior in multi-stage query engine will be the same
// as the query in v1 query engine.
case FLOAT:
return fieldSpec.isSingleValueField() ? createSqlType(SqlTypeName.REAL)
return fieldSpec.isSingleValueField() ? createSqlType(SqlTypeName.DOUBLE)
: createArrayType(createSqlType(SqlTypeName.REAL), -1);
case DOUBLE:
return fieldSpec.isSingleValueField() ? createSqlType(SqlTypeName.DOUBLE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ public void testRelDataTypeConversion() {
checkPrecisionScale(field, bigIntBasicSqlType);
break;
case "FLOAT_COL":
BasicSqlType floatBasicSqlType = new BasicSqlType(TYPE_SYSTEM, SqlTypeName.REAL);
Assert.assertEquals(field.getType(), floatBasicSqlType);
checkPrecisionScale(field, floatBasicSqlType);
break;
case "DOUBLE_COL":
BasicSqlType doubleBasicSqlType = new BasicSqlType(TYPE_SYSTEM, SqlTypeName.DOUBLE);
Assert.assertEquals(field.getType(), doubleBasicSqlType);
Expand Down