-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CALCITE-6257] StarRocks dialect implementation #3682
Conversation
211b4e8
to
e26b050
Compare
/** | ||
* A <code>SqlDialect</code> implementation for the StarRocks database. | ||
*/ | ||
public class StarRocksSqlDialect extends SqlDialect { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know anything about the StarRocks dialect, so my review will assume that these choices are correct for that dialect. I am reviewing only from the Calcite side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mihaibudiu Hello. As far as I know, the sql dialect of starrocks is compatible with mysql, but starrocks is an olap database that supports more data types and some special sql functions.
@@ -4506,13 +4600,16 @@ private void checkLiteral2(String expression, String expected) { | |||
String expectedPresto = "SELECT DATE_TRUNC('MINUTE', \"hire_date\")\n" | |||
+ "FROM \"foodmart\".\"employee\""; | |||
String expectedFirebolt = expectedPostgresql; | |||
String expectedStarRocks = "SELECT DATE_FORMAT(`hire_date`, '%Y-%m-%d %H:%i:00')\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks wrong, DATE_FORMAT returns a string, while DATE_TRUNC returns a date.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, this test case directly uses MysqlSqlDialect#unparseFloor
, MySQL/StarRocks Function DATE_FORMAT returns a string. date_format docs
StarRocks also support function date_trunc. Refer to the processing of PostgresqlSqlDialect
and replaced the FLOOR
function with DATE_TRUNC
|
||
@Override public @Nullable SqlNode getCastSpec(RelDataType type) { | ||
switch (type.getSqlTypeName()) { | ||
case TIMESTAMP: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused what's going on here.
If the Calcite TIMESTAMP type is called "DATETIME" in StarRocks, I am not sure whether this is the only case that needs changing. Can you write some tests that use TIMESTAMP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, Similar to MySQL, the Calcite TIMESTAMP type is called "DATETIME" in StarRocks. This processing refers to MysqlSqlDialect#getCastSpec
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added additional TIMESTAMP test:
RelToSqlConverterTest#testCastToTimestamp
RelToSqlConverterTest#testUnparseSqlIntervalQualifier
295dd55
to
1f000ec
Compare
Quality Gate passedIssues Measures |
Please solve the conflicts first. from starrocks doc, Starrocks say 'Compatible with MySQL', so maybe |
I'll try to handle it like this. |
1f000ec
to
a8c089f
Compare
Implementing StarRocks dialect in Calcite
https://issues.apache.org/jira/browse/CALCITE-6257