Skip to content

Commit

Permalink
Add starrocks keywords.
Browse files Browse the repository at this point in the history
  • Loading branch information
lingo-xp authored and wenshao committed Dec 12, 2024
1 parent 1bc2b19 commit 5aaf79c
Show file tree
Hide file tree
Showing 21 changed files with 247 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ public BigQueryOutputVisitor(StringBuilder appender) {
}

public BigQueryOutputVisitor(StringBuilder appender, boolean parameterized) {
super(appender, parameterized);
this.dbType = DbType.bigquery;
super(appender, DbType.bigquery, parameterized);
}

protected void printPartitionedBy(SQLCreateTableStatement x) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@

public class BlinkOutputVisitor extends SQLASTOutputVisitor implements BlinkVisitor {
public BlinkOutputVisitor(StringBuilder appender) {
super(appender);
super(appender, DbType.blink);
}

public BlinkOutputVisitor(StringBuilder appender, DbType dbType) {
super(appender, dbType);
}

public BlinkOutputVisitor(StringBuilder appender, boolean parameterized) {
super(appender, parameterized);
super(appender, DbType.blink, parameterized);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public CKOutputVisitor(StringBuilder appender, DbType dbType) {
}

public CKOutputVisitor(StringBuilder appender, boolean parameterized) {
super(appender, parameterized);
super(appender, DbType.clickhouse, parameterized);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public DB2OutputVisitor(StringBuilder appender) {
}

public DB2OutputVisitor(StringBuilder appender, boolean parameterized) {
super(appender, parameterized);
this.dbType = DbType.db2;
super(appender, DbType.db2, parameterized);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public H2OutputVisitor(StringBuilder appender, DbType dbType) {
}

public H2OutputVisitor(StringBuilder appender, boolean parameterized) {
super(appender, parameterized);
dbType = DbType.h2;
super(appender, DbType.h2, parameterized);
}

public boolean visit(SQLReplaceStatement x) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public HiveOutputVisitor(StringBuilder appender, DbType dbType) {
}

public HiveOutputVisitor(StringBuilder appender, boolean parameterized) {
super(appender, parameterized);
dbType = DbType.hive;
super(appender, DbType.hive, parameterized);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public InformixOutputVisitor(StringBuilder appender) {
}

public InformixOutputVisitor(StringBuilder appender, boolean parameterized) {
super(appender, parameterized);
dbType = DbType.informix;
super(appender, DbType.informix, parameterized);
}

protected void printSelectListBefore(SQLSelectQueryBlock x) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
}

public MySqlOutputVisitor(StringBuilder appender) {
super(appender);
super(appender, DbType.mysql);
}

public MySqlOutputVisitor(StringBuilder appender, boolean parameterized) {
super(appender, parameterized);
super(appender, DbType.mysql, parameterized);

try {
configFromProperty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.alibaba.druid.sql.dialect.hive.visitor.HiveOutputVisitor;
import com.alibaba.druid.sql.dialect.odps.ast.*;
import com.alibaba.druid.sql.visitor.VisitorFeature;
import com.alibaba.druid.util.OdpsUtils;

import java.math.BigDecimal;
import java.util.HashSet;
Expand Down Expand Up @@ -62,7 +61,6 @@ public OdpsOutputVisitor(boolean ucase) {

public OdpsOutputVisitor(StringBuilder appender) {
super(appender, DbType.odps);
dialect = OdpsUtils.DIALECT;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public OracleOutputVisitor(StringBuilder appender) {
}

public OracleOutputVisitor(StringBuilder appender, boolean printPostSemi) {
super(appender);
super(appender, DbType.oracle);
this.printPostSemi = printPostSemi;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@

public class OscarOutputVisitor extends SQLASTOutputVisitor implements OscarASTVisitor, OracleASTVisitor {
public OscarOutputVisitor(StringBuilder appender) {
super(appender);
this.dbType = DbType.oscar;
super(appender, DbType.oscar);
}

public OscarOutputVisitor(StringBuilder appender, boolean parameterized) {
super(appender, parameterized);
this.dbType = DbType.oscar;
super(appender, DbType.oscar, parameterized);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@
*/
package com.alibaba.druid.sql.dialect.phoenix.visitor;

import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.visitor.SQLASTOutputVisitor;

/**
* Created by wenshao on 16/9/13.
*/
public class PhoenixOutputVisitor extends SQLASTOutputVisitor implements PhoenixASTVisitor {
public PhoenixOutputVisitor(StringBuilder appender) {
super(appender);
super(appender, DbType.phoenix);
}

public PhoenixOutputVisitor(StringBuilder appender, boolean parameterized) {
super(appender, parameterized);
super(appender, DbType.phoenix, parameterized);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@

public class PGOutputVisitor extends SQLASTOutputVisitor implements PGASTVisitor, OracleASTVisitor {
public PGOutputVisitor(StringBuilder appender) {
super(appender);
this.dbType = DbType.postgresql;
super(appender, DbType.postgresql);
}

public PGOutputVisitor(StringBuilder appender, boolean parameterized) {
super(appender, parameterized);
this.dbType = DbType.postgresql;
super(appender, DbType.postgresql, parameterized);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,12 @@
* @since 2022-01-07
*/
public class PrestoOutputVisitor extends SQLASTOutputVisitor implements PrestoASTVisitor {
{
dbType = DbType.presto;
}

public PrestoOutputVisitor(StringBuilder appender) {
super(appender, DbType.presto);
}

public PrestoOutputVisitor(StringBuilder appender, boolean parameterized) {
super(appender, parameterized);
super(appender, DbType.presto, parameterized);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public SQLServerOutputVisitor(StringBuilder appender) {
}

public SQLServerOutputVisitor(StringBuilder appender, boolean parameterized) {
super(appender, parameterized);
this.dbType = DbType.sqlserver;
super(appender, DbType.sqlserver, parameterized);
}

public boolean visit(SQLServerSelectQueryBlock x) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,20 @@

public class StarRocksOutputVisitor extends SQLASTOutputVisitor implements StarRocksASTVisitor {
{
this.dbType = DbType.starrocks;
this.shardingSupport = true;
this.quote = '`';
}

public StarRocksOutputVisitor(StringBuilder appender) {
super(appender);
super(appender, DbType.starrocks);
}

public StarRocksOutputVisitor(StringBuilder appender, DbType dbType) {
super(appender, dbType);
}

public StarRocksOutputVisitor(StringBuilder appender, boolean parameterized) {
super(appender, parameterized);
super(appender, DbType.starrocks, parameterized);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,19 @@ public SQLASTOutputVisitor(StringBuilder appender) {
public SQLASTOutputVisitor(StringBuilder appender, DbType dbType) {
this.appender = appender;
this.dbType = dbType;
this.dialect = SQLDialect.of(dbType);
}

public SQLASTOutputVisitor(StringBuilder appender, boolean parameterized) {
this.appender = appender;
this.config(VisitorFeature.OutputParameterized, parameterized);
}
public SQLASTOutputVisitor(StringBuilder appender, DbType dbType, boolean parameterized) {
this.appender = appender;
this.dbType = dbType;
this.dialect = SQLDialect.of(dbType);
this.config(VisitorFeature.OutputParameterized, parameterized);
}

public int getReplaceCount() {
return this.replaceCount;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
quote=`
151 changes: 151 additions & 0 deletions core/src/main/resources/META-INF/druid/parser/starrocks/keywords
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
ADD
ALL
ALTER
ANALYZE
AND
ARRAY
AS
ASC
BETWEEN
BIGINT
BITMAP
BOTH
BY
CASE
CHAR
CHARACTER
CHECK
COLLATE
COLUMN
COMPACTION
CONVERT
CREATE
CROSS
CUBE
CURRENT_DATE
CURRENT_TIME
CURRENT_TIMESTAMP
CURRENT_USER
CURRENT_ROLE
DATABASE
DATABASES
DECIMAL
DECIMALV2
DECIMAL32
DECIMAL64
DECIMAL128
DEFAULT
DELETE
DENSE_RANK
DESC
DESCRIBE
DISTINCT
DOUBLE
DROP
DUAL
DEFERRED
ELSE
EXCEPT
EXISTS
EXPLAIN
FALSE
FIRST_VALUE
FLOAT
FOR
FORCE
FROM
FULL
FUNCTION
GRANT
GROUP
GROUPS
GROUPING
GROUPING_ID
HAVING
HLL
HOST
IF
IGNORE
IN
INDEX
INFILE
INNER
INSERT
INT
INTEGER
INTERSECT
INTO
IS
IMMEDIATE
JOIN
JSON
KEY
KEYS
KILL
LAG
LARGEINT
LAST_VALUE
LATERAL
LEAD
LEFT
LIKE
LIMIT
LOAD
LOCALTIME
LOCALTIMESTAMP
MAXVALUE
MINUS
MOD
NTILE
NOT
NULL
ON
OR
ORDER
OUTER
OUTFILE
OVER
PARTITION
PERCENTILE
PRIMARY
PROCEDURE
QUALIFY
RANGE
RANK
READ
REGEXP
RELEASE
RENAME
REPLACE
REVOKE
RIGHT
RLIKE
ROW
ROWS
ROW_NUMBER
SCHEMA
SCHEMAS
SELECT
SET
SET_VAR
SHOW
SMALLINT
SYSTEM
TABLE
TERMINATED
TEXT
THEN
TINYINT
TO
TRUE
UNION
UNIQUE
UNSIGNED
UPDATE
USE
USING
VALUES
VARCHAR
WHEN
WHERE
WITH
Loading

0 comments on commit 5aaf79c

Please sign in to comment.