mirror of https://github.com/alibaba/druid.git
Fix holo/ck array date type parse/output issue. (#6434)
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (11, ubuntu-latest) (push) Waiting to run
Details
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (17, ubuntu-latest) (push) Waiting to run
Details
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (21, ubuntu-latest) (push) Waiting to run
Details
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (8, ubuntu-latest) (push) Waiting to run
Details
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (11, ubuntu-latest) (push) Waiting to run
Details
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (17, ubuntu-latest) (push) Waiting to run
Details
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (21, ubuntu-latest) (push) Waiting to run
Details
Java CI / Test JDK ${{ matrix.java }}, ${{ matrix.os }} (8, ubuntu-latest) (push) Waiting to run
Details
* Fix holo/ck array date type parse/output issue. * Fix holo/ck array date type parse/output issue. * Fix holo/ck array date type parse/output issue.
This commit is contained in:
parent
2fa64f1356
commit
e206890a01
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package com.alibaba.druid.sql.dialect.clickhouse.parser;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLArrayDataType;
|
||||
import com.alibaba.druid.sql.ast.SQLDataType;
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
|
@ -162,4 +163,14 @@ public class CKExprParser extends SQLExprParser {
|
|||
|
||||
return struct;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SQLArrayDataType parseArrayDataType() {
|
||||
lexer.nextToken();
|
||||
accept(Token.LPAREN);
|
||||
SQLDataType itemType = parseDataType();
|
||||
SQLArrayDataType array = new SQLArrayDataType(itemType, dbType);
|
||||
accept(Token.RPAREN);
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,33 +180,6 @@ public class CKOutputVisitor extends SQLASTOutputVisitor implements CKASTVisitor
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLArrayDataType x) {
|
||||
final List<SQLExpr> arguments = x.getArguments();
|
||||
if (Boolean.TRUE.equals(x.getAttribute("ads.arrayDataType"))) {
|
||||
x.getComponentType().accept(this);
|
||||
print('[');
|
||||
printAndAccept(arguments, ", ");
|
||||
print(']');
|
||||
} else {
|
||||
SQLDataType componentType = x.getComponentType();
|
||||
if (componentType != null) {
|
||||
print0(ucase ? "Array<" : "array<");
|
||||
componentType.accept(this);
|
||||
print('>');
|
||||
} else {
|
||||
print0(ucase ? "Array" : "array");
|
||||
}
|
||||
|
||||
if (arguments.size() > 0) {
|
||||
print('(');
|
||||
printAndAccept(arguments, ", ");
|
||||
print(')');
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(CKAlterTableUpdateStatement x) {
|
||||
print0(ucase ? "ALTER TABLE " : "alter table ");
|
||||
|
@ -367,4 +340,12 @@ public class CKOutputVisitor extends SQLASTOutputVisitor implements CKASTVisitor
|
|||
print(')');
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLArrayDataType x) {
|
||||
print0(ucase ? "ARRAY(" : "array(");
|
||||
x.getComponentType().accept(this);
|
||||
print(')');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.alibaba.druid.sql.dialect.hologres.visitor;
|
||||
|
||||
import com.alibaba.druid.DbType;
|
||||
import com.alibaba.druid.sql.ast.SQLArrayDataType;
|
||||
import com.alibaba.druid.sql.ast.SQLPartitionBy;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.visitor.PGOutputVisitor;
|
||||
|
@ -27,4 +28,12 @@ public class HologresOutputVisitor extends PGOutputVisitor {
|
|||
print0(ucase ? "PARTITION BY " : "partition by ");
|
||||
partitionBy.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLArrayDataType x) {
|
||||
print0(ucase ? "ARRAY<" : "array<");
|
||||
x.getComponentType().accept(this);
|
||||
print('>');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4200,7 +4200,7 @@ public class SQLExprParser extends SQLParser {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (lexer.identifierEquals(FnvHash.Constants.ARRAY)) {
|
||||
if (lexer.identifierEquals(FnvHash.Constants.ARRAY) || lexer.token() == Token.ARRAY) {
|
||||
return parseArrayDataType();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
CREATE TABLE test.test (
|
||||
`aa` Array(UInt64) )
|
||||
ENGINE = MergeTree()
|
||||
--------------------
|
||||
CREATE TABLE test.test (
|
||||
`aa` ARRAY(UInt64)
|
||||
) ENGINE = MergeTree()
|
||||
------------------------------------------------------------------------------------------------------------------------
|
||||
CREATE TABLE tmp.tmp_exp_mobile_tzfx_tzqy_m_20240506
|
||||
(
|
||||
date_code Int32 COMMENT '日期编码',
|
||||
|
@ -176,8 +184,8 @@ CREATE TABLE if not exists etda.mytable1
|
|||
--------------------
|
||||
CREATE TABLE IF NOT EXISTS etda.mytable1 (
|
||||
`id` UInt64,
|
||||
`action_parameter_uint64_list` Array(UInt64),
|
||||
`action_parameter_string_list` Array(String)
|
||||
`action_parameter_uint64_list` ARRAY(UInt64),
|
||||
`action_parameter_string_list` ARRAY(String)
|
||||
)
|
||||
------------------------------------------------------------------------------------------------------------------------
|
||||
SELECT level, sum(cnt) OVER (PARTITION BY NULL ORDER BY level DESC) AS cnt
|
||||
|
|
|
@ -28,10 +28,10 @@ CREATE TABLE replicated_orders (
|
|||
product_id LowCardinality(UInt32),
|
||||
quantity Int32,
|
||||
price Decimal(10, 2),
|
||||
array1 Array(UInt8),
|
||||
array1 ARRAY(UInt8),
|
||||
tuple1 Tuple(UInt8, String),
|
||||
map1 MAP(String, UInt64),
|
||||
variant1 Variant(String, Array(UInt8)),
|
||||
variant1 Variant(String, ARRAY(UInt8)),
|
||||
null1 Nullable(String)
|
||||
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/replicated_orders', '{replica}')
|
||||
PARTITION BY order_date
|
||||
|
@ -90,10 +90,10 @@ CREATE TABLE replicated_orders (
|
|||
product_id LowCardinality(UInt32),
|
||||
quantity Int32,
|
||||
price Decimal(10, 2),
|
||||
array1 Array(UInt8),
|
||||
array1 ARRAY(UInt8),
|
||||
tuple1 Tuple(UInt8, String),
|
||||
map1 MAP(String, UInt64),
|
||||
variant1 Variant(String, Array(UInt8)),
|
||||
variant1 Variant(String, ARRAY(UInt8)),
|
||||
null1 Nullable(String)
|
||||
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/replicated_orders', '{replica}')
|
||||
PARTITION BY (order_date, quantity)
|
||||
|
|
|
@ -2,6 +2,7 @@ CREATE TABLE IF NOT EXISTS my_partitioned_table (
|
|||
id INT,
|
||||
name text,
|
||||
value FLOAT ,
|
||||
arr ARRAY<INT>,
|
||||
dt TEXT not null,
|
||||
region TEXT not null
|
||||
)
|
||||
|
@ -15,6 +16,7 @@ CREATE TABLE IF NOT EXISTS my_partitioned_table (
|
|||
id INT,
|
||||
name text,
|
||||
value FLOAT,
|
||||
arr ARRAY<INT>,
|
||||
dt TEXT NOT NULL,
|
||||
region TEXT NOT NULL
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue