-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Remove parsing of integer literals (#3019)
* perf: Remove parsing of integer literals Old code converted INT and BIGINT literals to strings and then parsed them when processing every row. This adds unnecessary overhead to the row processing and so has been replaced with just the int/long value. Also improved error handling of numeric parsing: DOUBLEs now throw a parse exception if they result in NaN or Infinity and parse exceptions include correct location. * Rohan's requested changes.
- Loading branch information
1 parent
aae1357
commit 6195b76
Showing
11 changed files
with
239 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
ksql-functional-tests/src/test/resources/query-validation-tests/literals.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
{ | ||
"tests": [ | ||
{ | ||
"name": "BOOLEAN literal", | ||
"statements": [ | ||
"CREATE STREAM INPUT (ID bigint) WITH (kafka_topic='input', value_format='DELIMITED');", | ||
"CREATE STREAM OUTPUT AS select id, TRUE, True, true, FALSE, False, false FROM INPUT;" | ||
], | ||
"inputs": [ | ||
{"topic": "input", "value": "0"} | ||
], | ||
"outputs": [ | ||
{"topic": "OUTPUT", "value": "0,true,true,true,false,false,false"} | ||
] | ||
}, | ||
{ | ||
"name": "INT literal min/max", | ||
"statements": [ | ||
"CREATE STREAM INPUT (ID bigint) WITH (kafka_topic='input', value_format='DELIMITED');", | ||
"CREATE STREAM OUTPUT AS select id, -00002147483647 AS MIN, 000002147483647 AS MAX FROM INPUT;" | ||
], | ||
"inputs": [ | ||
{"topic": "input", "value": "0"} | ||
], | ||
"outputs": [ | ||
{"topic": "OUTPUT", "value": "0,-2147483647,2147483647"} | ||
] | ||
}, | ||
{ | ||
"name": "BIGINT literal min/max", | ||
"note": "Long.MIN_VALUE is actually -9223372036854775808, which KSQL can not handle as the LongLiteral is stored unsigned", | ||
"statements": [ | ||
"CREATE STREAM INPUT (ID bigint) WITH (kafka_topic='input', value_format='DELIMITED');", | ||
"CREATE STREAM OUTPUT AS select id, -00009223372036854775807 AS MIN, 000009223372036854775807 AS MAX FROM INPUT;" | ||
], | ||
"inputs": [ | ||
{"topic": "input", "value": "0"} | ||
], | ||
"outputs": [ | ||
{"topic": "OUTPUT", "value": "0,-9223372036854775807,9223372036854775807"} | ||
] | ||
}, | ||
{ | ||
"name": "DOUBLE literal min/max", | ||
"statements": [ | ||
"CREATE STREAM INPUT (ID bigint) WITH (kafka_topic='input', value_format='DELIMITED');", | ||
"CREATE STREAM OUTPUT AS select id, 04.90E-324 AS MIN_VALUE, -4.9E-324 AS NEG_MIN_VALUE, 2.2250738585072014E-308 AS MIN_NORMAL, -2.2250738585072014E-308 AS NEG_MIN_NORMAL, 1.7976931348623157E308 AS MAX_VALUE, -1.7976931348623157E308 AS NEG_MAX_VALUE FROM INPUT;" | ||
], | ||
"inputs": [ | ||
{"topic": "input", "value": "0"} | ||
], | ||
"outputs": [ | ||
{"topic": "OUTPUT", "value": "0,4.9E-324,-4.9E-324,2.2250738585072014E-308,-2.2250738585072014E-308,1.7976931348623157E308,-1.7976931348623157E308"} | ||
] | ||
}, | ||
{ | ||
"name": "BIGINT literal positive overflow", | ||
"statements": [ | ||
"CREATE STREAM INPUT (ID bigint) WITH (kafka_topic='input', value_format='DELIMITED');", | ||
"CREATE STREAM OUTPUT AS select id, 9223372036854775808 FROM INPUT;" | ||
], | ||
"expectedException": { | ||
"type": "io.confluent.ksql.parser.exception.ParseFailedException", | ||
"message": "Failed to prepare statement: line 2:37: Invalid numeric literal: 9223372036854775808" | ||
} | ||
}, | ||
{ | ||
"name": "BIGINT literal negative overflow", | ||
"note": "Long.MIN_VALUE is actually -9223372036854775808, which KSQL can not handle as the LongLiteral is stored unsigned", | ||
"statements": [ | ||
"CREATE STREAM INPUT (ID bigint) WITH (kafka_topic='input', value_format='DELIMITED');", | ||
"CREATE STREAM OUTPUT AS select id, -9223372036854775808 FROM INPUT;" | ||
], | ||
"expectedException": { | ||
"type": "io.confluent.ksql.parser.exception.ParseFailedException", | ||
"message": "Failed to prepare statement: line 2:38: Invalid numeric literal: 9223372036854775808" | ||
} | ||
}, | ||
{ | ||
"name": "DOUBLE literal positive overflow", | ||
"statements": [ | ||
"CREATE STREAM INPUT (ID bigint) WITH (kafka_topic='input', value_format='DELIMITED');", | ||
"CREATE STREAM OUTPUT AS select id, 1.7976931348623159E308 FROM INPUT;" | ||
], | ||
"expectedException": { | ||
"type": "io.confluent.ksql.parser.exception.ParseFailedException", | ||
"message": "Failed to prepare statement: line 2:37: Number overflows DOUBLE: 1.7976931348623159E308" | ||
} | ||
}, | ||
{ | ||
"name": "DOUBLE literal negative overflow", | ||
"statements": [ | ||
"CREATE STREAM INPUT (ID bigint) WITH (kafka_topic='input', value_format='DELIMITED');", | ||
"CREATE STREAM OUTPUT AS select id, -1.7976931348623159E308 FROM INPUT;" | ||
], | ||
"expectedException": { | ||
"type": "io.confluent.ksql.parser.exception.ParseFailedException", | ||
"message": "Failed to prepare statement: line 2:38: Number overflows DOUBLE: 1.7976931348623159E308" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.