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 @@ -18,6 +18,7 @@
package org.apache.shardingsphere.sql.parser.statement.core.segment.dml.item;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.column.ColumnSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.AliasAvailable;
Expand All @@ -29,6 +30,7 @@
/**
* Column projection segment.
*/
@RequiredArgsConstructor
@Setter
@Getter
public final class ColumnProjectionSegment implements ProjectionSegment, AliasAvailable {
Expand All @@ -39,10 +41,6 @@ public final class ColumnProjectionSegment implements ProjectionSegment, AliasAv

private boolean visible = true;

public ColumnProjectionSegment(final ColumnSegment columnSegment) {
column = columnSegment;
}

@Override
public String getColumnLabel() {
return getAliasName().orElse(column.getIdentifier().getValue());
Expand Down
2 changes: 2 additions & 0 deletions test/it/parser/src/main/resources/case/dal/kill.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@
<kill sql-case-id="kill_connection_with_numeric_id" process-id="16" />
<kill sql-case-id="kill_query_with_numeric_id" process-id="16" />
<kill sql-case-id="kill_with_numeric_id" process-id="16" />
<kill sql-case-id="kill_with_identifier_doris" process-id="job_session" />
<kill sql-case-id="kill_query_with_at_identifier_doris" process-id="@session_id" />
</sql-parser-test-cases>
10 changes: 10 additions & 0 deletions test/it/parser/src/main/resources/case/dal/set.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,14 @@
</parameter-assign>
</set-parameter>
<set-parameter sql-case-id="set_session_authorization" />
<set-parameter sql-case-id="set_persist_system_variable_doris">
<parameter-assign value="200">
<parameter name="max_connections" scope="PERSIST" />
</parameter-assign>
</set-parameter>
<set-parameter sql-case-id="set_persist_only_system_variable_doris">
<parameter-assign value="'+08:00'">
<parameter name="time_zone" scope="PERSIST_ONLY" />
</parameter-assign>
</set-parameter>
</sql-parser-test-cases>
4 changes: 4 additions & 0 deletions test/it/parser/src/main/resources/case/dcl/create-user.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,8 @@
<create-user sql-case-id="create_azure_ad_user_without_login" />
<create-user sql-case-id="create _user_with_option" />
<create-user sql-case-id="create_user_with_user_auth_option" />
<create-user sql-case-id="create_user_require_ssl_doris" />
<create-user sql-case-id="create_user_require_none_doris" />
<create-user sql-case-id="create_user_require_x509_doris" />
<create-user sql-case-id="create_user_require_tls_specified_doris" />
</sql-parser-test-cases>
22 changes: 22 additions & 0 deletions test/it/parser/src/main/resources/case/ddl/alter-table.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2570,4 +2570,26 @@
<new-partition name="partition2" start-index="54" stop-index="63" />
</rename-partition>
</alter-table>

<alter-table sql-case-id="alter_table_add_column_first_doris">
<table name="t_order" start-index="12" stop-index="18" />
<add-column>
<column-definition type="INT" start-index="24" stop-index="34">
<column name="column9" start-index="24" stop-index="30" />
</column-definition>
<column-position start-index="36" stop-index="40" />
</add-column>
</alter-table>

<alter-table sql-case-id="alter_table_add_column_after_doris">
<table name="t_order" start-index="12" stop-index="18" />
<add-column>
<column-definition type="INT" start-index="24" stop-index="35">
<column name="column10" start-index="24" stop-index="31" />
</column-definition>
<column-position start-index="37" stop-index="50">
<column name="order_id" start-index="43" stop-index="50" />
</column-position>
</add-column>
</alter-table>
</sql-parser-test-cases>
15 changes: 15 additions & 0 deletions test/it/parser/src/main/resources/case/ddl/create-view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@
</select>
</create-view>

<create-view sql-case-id="create_view_with_owner_doris" view-definition="SELECT order_id, user_id FROM t_order">
<view name="v_sales" start-index="12" stop-index="25">
<owner name="report" start-index="12" stop-index="17" />
</view>
<select>
<projections start-index="37" stop-index="53">
<column-projection name="order_id" start-index="37" stop-index="44" />
<column-projection name="user_id" start-index="47" stop-index="53" />
</projections>
<from>
<simple-table name="t_order" start-index="60" stop-index="66" />
</from>
</select>
</create-view>

<create-view sql-case-id="create_view_with_columns_doris" view-definition="SELECT k1, k2 FROM example_table">
<view name="example_view" start-index="12" stop-index="23">
<column name="c1" start-index="26" stop-index="27" />
Expand Down
10 changes: 10 additions & 0 deletions test/it/parser/src/main/resources/case/dml/call.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,14 @@
<literal-expression value="member2@localhost" start-index="45" stop-index="63"/>
</procedure-parameter>
</call>

<call sql-case-id="call_with_owner_doris">
<procedure-name name="analytics.proc_demo" start-index="5" stop-index="23"/>
<procedure-parameter>
<parameter-marker-expression parameter-index="0" start-index="25" stop-index="25"/>
</procedure-parameter>
<procedure-parameter>
<parameter-marker-expression parameter-index="1" start-index="28" stop-index="28"/>
</procedure-parameter>
</call>
</sql-parser-test-cases>
30 changes: 30 additions & 0 deletions test/it/parser/src/main/resources/case/dml/select-combine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,36 @@
</combine>
</select>

<select sql-case-id="select_union_doris">
<projections start-index="7" stop-index="7">
<expression-projection text="1" start-index="7" stop-index="7">
<expr>
<literal-expression value="1" start-index="7" stop-index="7" />
</expr>
</expression-projection>
</projections>
<combine combine-type="UNION" start-index="0" stop-index="22">
<left>
<projections start-index="7" stop-index="7">
<expression-projection text="1" start-index="7" stop-index="7">
<expr>
<literal-expression value="1" start-index="7" stop-index="7" />
</expr>
</expression-projection>
</projections>
</left>
<right>
<projections start-index="22" stop-index="22">
<expression-projection text="2" start-index="22" stop-index="22">
<expr>
<literal-expression value="2" start-index="22" stop-index="22" />
</expr>
</expression-projection>
</projections>
</right>
</combine>
</select>

<select sql-case-id="select_union_all">
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4184,6 +4184,26 @@
</from>
</select>

<select sql-case-id="select_json_separator_doris">
<projections start-index="7" stop-index="37">
<expression-projection text="JSON_SEPARATOR(order_id, '$.a')" start-index="7" stop-index="37">
<expr>
<function function-name="JSON_SEPARATOR" text="JSON_SEPARATOR(order_id, '$.a')" start-index="7" stop-index="37">
<parameter>
<column name="order_id" start-index="22" stop-index="29" />
</parameter>
<parameter>
<literal-expression value="$.a" start-index="32" stop-index="36" />
</parameter>
</function>
</expr>
</expression-projection>
</projections>
<from>
<simple-table name="t_order" start-index="44" stop-index="50" />
</from>
</select>

<select sql-case-id="select_json_type">
<projections start-index="7" stop-index="26">
<expression-projection start-index="7" stop-index="26" text="JSON_TYPE('[1,2,3]')">
Expand Down
34 changes: 34 additions & 0 deletions test/it/parser/src/main/resources/case/dml/select-window.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,40 @@
</from>
</select>

<select sql-case-id="select_window_first_value_doris">
<projections start-index="7" stop-index="53">
<expression-projection text="FIRST_VALUE(v) OVER (PARTITION BY k ORDER BY v)" start-index="7" stop-index="53">
<expr>
<function function-name="FIRST_VALUE" text="FIRST_VALUE(v) OVER (PARTITION BY k ORDER BY v)" start-index="7" stop-index="53">
<parameter>
<column name="v" start-index="19" stop-index="19" />
</parameter>
</function>
</expr>
</expression-projection>
</projections>
<from>
<simple-table name="t_order" start-index="60" stop-index="66" />
</from>
</select>

<select sql-case-id="select_window_last_value_doris">
<projections start-index="7" stop-index="101">
<expression-projection text="LAST_VALUE(v) OVER (PARTITION BY k ORDER BY v ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)" start-index="7" stop-index="101">
<expr>
<function function-name="LAST_VALUE" text="LAST_VALUE(v) OVER (PARTITION BY k ORDER BY v ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)" start-index="7" stop-index="101">
<parameter>
<column name="v" start-index="18" stop-index="18" />
</parameter>
</function>
</expr>
</expression-projection>
</projections>
<from>
<simple-table name="t_order" start-index="108" stop-index="114" />
</from>
</select>

<select sql-case-id="select_window_frame_doris">
<projections start-index="7" stop-index="86">
<aggregation-projection type="SUM" expression="SUM(v) OVER (PARTITION BY k ORDER BY v ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)" start-index="7" stop-index="86">
Expand Down
29 changes: 29 additions & 0 deletions test/it/parser/src/main/resources/case/dml/select.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11934,4 +11934,33 @@
<simple-table name="DUAL" start-index="14" stop-index="17" />
</from>
</select>

<select sql-case-id="select_straight_join_doris">
<projections start-index="21" stop-index="21">
<shorthand-projection start-index="21" stop-index="21" />
</projections>
<from>
<simple-table name="t_order" start-index="28" stop-index="34" />
</from>
</select>

<select sql-case-id="select_for_update_doris">
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
</projections>
<from start-index="14" stop-index="20">
<simple-table name="t_order" start-index="14" stop-index="20" />
</from>
<lock start-index="22" stop-index="31" />
</select>

<select sql-case-id="select_function_with_owner_doris">
<projections start-index="7" stop-index="27">
<expression-projection text="analytics.custom_fn()" start-index="7" stop-index="27">
<expr>
<function function-name="analytics.custom_fn()" text="analytics.custom_fn()" start-index="7" stop-index="27" />
</expr>
</expression-projection>
</projections>
</select>
</sql-parser-test-cases>
2 changes: 2 additions & 0 deletions test/it/parser/src/main/resources/sql/supported/dal/kill.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@
<sql-case id="kill_connection_with_numeric_id" value="KILL CONNECTION 16" db-types="Doris" />
<sql-case id="kill_query_with_numeric_id" value="KILL QUERY 16" db-types="Doris" />
<sql-case id="kill_with_numeric_id" value="KILL 16" db-types="Doris" />
<sql-case id="kill_with_identifier_doris" value="KILL job_session" db-types="Doris" />
<sql-case id="kill_query_with_at_identifier_doris" value="KILL QUERY @session_id" db-types="Doris" />
</sql-cases>
2 changes: 2 additions & 0 deletions test/it/parser/src/main/resources/sql/supported/dal/set.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@
<sql-case id="set_charset_postgresql" value="SET NAMES 'UTF8'" db-types="PostgreSQL" />
<sql-case id="set_client_encoding" value="SET CLIENT_ENCODING TO 'UTF8'" db-types="PostgreSQL" />
<sql-case id="set_session_authorization" value="SET SESSION AUTHORIZATION user1 PASSWORD 'password'" db-types="openGauss" />
<sql-case id="set_persist_system_variable_doris" value="SET PERSIST max_connections = 200" db-types="Doris" />
<sql-case id="set_persist_only_system_variable_doris" value="SET PERSIST_ONLY time_zone = '+08:00'" db-types="Doris" />
</sql-cases>
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
<sql-case id="create_user_with_password_options" value="CREATE USER user1 DEFAULT ROLE role1 PASSWORD EXPIRE DEFAULT PASSWORD HISTORY DEFAULT" db-types="MySQL,Doris" />
<sql-case id="create_user_with_lock_option" value="CREATE USER user1 DEFAULT ROLE role1 ACCOUNT LOCK" db-types="MySQL,Doris" />
<sql-case id="create_user_with_options" value="CREATE USER user1 DEFAULT ROLE role1 WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 1 PASSWORD EXPIRE DEFAULT PASSWORD HISTORY DEFAULT ACCOUNT LOCK" db-types="MySQL,Doris" />
<sql-case id="create_user_require_ssl_doris" value="CREATE USER user_ssl REQUIRE SSL" db-types="Doris" />
<sql-case id="create_user_require_none_doris" value="CREATE USER user_no_tls REQUIRE NONE" db-types="Doris" />
<sql-case id="create_user_require_x509_doris" value="CREATE USER user_x509 REQUIRE X509" db-types="Doris" />
<sql-case id="create_user_require_tls_specified_doris" value="CREATE USER user_tls REQUIRE SUBJECT 'subj' ISSUER 'issuer' CIPHER 'cipher_name'" db-types="Doris" />
<sql-case id="create_external_user" value="CREATE USER user1 IDENTIFIED EXTERNALLY" db-types="Oracle" />
<sql-case id="create_global_user" value="CREATE USER user1 IDENTIFIED GLOBALLY" db-types="Oracle" />
<sql-case id="create_user_with_password" value="CREATE USER user1 IDENTIFIED BY RANDOM password default role role1" db-types="H2,MySQL" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
<sql-case id="alter_table_add_column_with_first" value="ALTER TABLE t_order ADD column3 VARCHAR(10) FIRST" db-types="MySQL" />
<sql-case id="alter_table_add_column_with_after" value="ALTER TABLE t_order ADD column4 VARCHAR(10) AFTER order_id" db-types="MySQL" />
<sql-case id="alter_table_add_column_with_first_after" value="ALTER TABLE t_order ADD column5 VARCHAR(10) FIRST, ADD column6 VARCHAR(10) FIRST, ADD column7 VARCHAR(10) AFTER column5, ADD column8 VARCHAR(10) AFTER column6" db-types="MySQL" />
<sql-case id="alter_table_add_column_first_doris" value="ALTER TABLE t_order ADD column9 INT FIRST" db-types="Doris" />
<sql-case id="alter_table_add_column_after_doris" value="ALTER TABLE t_order ADD column10 INT AFTER order_id" db-types="Doris" />
<sql-case id="alter_table_modify_column" value="ALTER TABLE t_order MODIFY column4 VARCHAR(20)" db-types="MySQL,Oracle" />
<sql-case id="alter_table_modify_columns" value="ALTER TABLE t_order MODIFY column4 VARCHAR(20), MODIFY column5 VARCHAR(20), MODIFY column6 VARCHAR(20)" db-types="MySQL" />
<sql-case id="alter_table_modify_column_with_first" value="ALTER TABLE t_order MODIFY status VARCHAR(20) FIRST" db-types="MySQL" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<sql-case id="create_view_with_udf_nested_fun" value="CREATE VIEW V_T1_C AS SELECT DB29023216.TESTFUNC(NOW())" db-types="MySQL" />
<sql-case id="create_view_with_udf_arg" value="CREATE VIEW V_T1_C AS SELECT DB29023216.TESTFUNC(1,2,3,4)" db-types="MySQL" />
<sql-case id="create_view" value="CREATE VIEW comedies AS SELECT * FROM films WHERE kind = 'Comedy'" db-types="MySQL,PostgreSQL,openGauss,SQLServer,Doris" />
<sql-case id="create_view_with_owner_doris" value="CREATE VIEW report.v_sales AS SELECT order_id, user_id FROM t_order" db-types="Doris" />
<sql-case id="create_view_with_columns_doris" value="CREATE VIEW example_view (c1, c2) AS SELECT k1, k2 FROM example_table" db-types="Doris" />
<sql-case id="create_view_with_check_option" value="CREATE VIEW universal_comedies AS SELECT * FROM comedies WHERE classification = 'U' WITH LOCAL CHECK OPTION" db-types="PostgreSQL,openGauss" />
<sql-case id="create_view_with_recursive" value="CREATE RECURSIVE VIEW public.nums_1_100 (n) AS VALUES (1) UNION ALL SELECT n+1 FROM nums_1_100 WHERE n = 100" db-types="PostgreSQL,openGauss" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<sql-case id="call_with_parameters_all_placeholder" value="CALL p(?, ?) " db-types="MySQL,Doris" />
<sql-case id="call_with_parameters_all_expression" value="CALL p('user', 'order')" db-types="MySQL,Doris" />
<sql-case id="call_with_parameters_mix" value="CALL p(@order_id, 'user', ?)" db-types="MySQL,Doris" />
<sql-case id="call_with_owner_doris" value="CALL analytics.proc_demo(?, ?)" db-types="Doris" />
<sql-case id="call_with_named_notation_with_null" value="CALL p(a =&gt; null, b =&gt; 8, c =&gt; 2);" db-types="PostgreSQL" />
<sql-case id="call_with_named_notation" value="CALL p(b =&gt; 8, c =&gt; 2, a =&gt; 0);" db-types="PostgreSQL" />
<sql-case id="call_with_mixed_notation" value="CALL p(null, 7, c =&gt; 2);" db-types="PostgreSQL" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
<sql-case id="select_json_parse" value="SELECT JSON_PARSE('{&quot;k1&quot;:&quot;v31&quot;,&quot;k2&quot;:300}')" db-types="Doris" />
<sql-case id="select_json_parse_error_to_null" value="SELECT JSON_PARSE('invalid json')" db-types="Doris" />
<sql-case id="select_json_parse_error_to_value" value="SELECT JSON_PARSE('invalid json', '{}')" db-types="Doris" />
<sql-case id="select_json_separator_doris" value="SELECT JSON_SEPARATOR(order_id, '$.a') FROM t_order" db-types="Doris" />
<sql-case id="select_std" value="SELECT STD(1)" db-types="MySQL" />
<sql-case id="select_stddev" value="SELECT STDDEV(1)" db-types="MySQL" />
<sql-case id="select_stddev_pop" value="SELECT STDDEV_POP(1)" db-types="MySQL" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@
<sql-case id="select_window" value="SELECT user_id, ROW_NUMBER() OVER w AS 'row_number', RANK() OVER w AS 'rank', DENSE_RANK() OVER w AS 'dense_rank' FROM t_order WHERE order_id = ? WINDOW w AS (ORDER BY user_id)" db-types="MySQL,Doris" />
<sql-case id="select_window_partition_order_doris" value="SELECT ROW_NUMBER() OVER (PARTITION BY k ORDER BY v) FROM t_order" db-types="Doris" />
<sql-case id="select_window_lead_lag_doris" value="SELECT LEAD(v) OVER (PARTITION BY k ORDER BY v) FROM t_order" db-types="Doris" />
<sql-case id="select_window_first_value_doris" value="SELECT FIRST_VALUE(v) OVER (PARTITION BY k ORDER BY v) FROM t_order" db-types="Doris" />
<sql-case id="select_window_last_value_doris" value="SELECT LAST_VALUE(v) OVER (PARTITION BY k ORDER BY v ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t_order" db-types="Doris" />
<sql-case id="select_window_frame_doris" value="SELECT SUM(v) OVER (PARTITION BY k ORDER BY v ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t_order" db-types="Doris" />
</sql-cases>
Loading