Skip to content

Commit adf27cc

Browse files
committed
Fixed PR comments ydb-platform#3
1 parent 1f908de commit adf27cc

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

ydb/core/protos/flat_scheme_op.proto

+1-1
Original file line numberDiff line numberDiff line change
@@ -1806,7 +1806,7 @@ message TExternalTableDescription {
18061806
optional string Location = 6;
18071807
repeated TColumnDescription Columns = 7;
18081808
optional bytes Content = 8;
1809-
optional bool ReplaceIfExists = 9;
1809+
optional bool ReplaceIfExists = 9; // Only applicable for `create external table` operation
18101810
}
18111811

18121812
// Access without authorization

ydb/library/yql/sql/v1/format/sql_format_ut.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,8 @@ Y_UNIT_TEST_SUITE(CheckSqlFormatter) {
354354
"CREATE EXTERNAL DATA SOURCE usEr WITH (a = \"b\");\n"},
355355
{"creAte exTernAl daTa SouRce if not exists usEr With (a = \"b\")",
356356
"CREATE EXTERNAL DATA SOURCE IF NOT EXISTS usEr WITH (a = \"b\");\n"},
357+
{"creAte oR rePlaCe exTernAl daTa SouRce usEr With (a = \"b\")",
358+
"CREATE OR REPLACE EXTERNAL DATA SOURCE usEr WITH (a = \"b\");\n"},
357359
{"create external data source eds with (a=\"a\",b=\"b\",c = true)",
358360
"CREATE EXTERNAL DATA SOURCE eds WITH (\n\ta = \"a\",\n\tb = \"b\",\n\tc = TRUE\n);\n"},
359361
{"alter external data source eds set a true, reset (b, c), set (x=y, z=false)",
@@ -388,6 +390,8 @@ Y_UNIT_TEST_SUITE(CheckSqlFormatter) {
388390
TCases cases = {
389391
{"creAte exTernAl TabLe usEr (a int) With (a = \"b\")",
390392
"CREATE EXTERNAL TABLE usEr (\n\ta int\n)\nWITH (a = \"b\");\n"},
393+
{"creAte oR rePlaCe exTernAl TabLe usEr (a int) With (a = \"b\")",
394+
"CREATE OR REPLACE EXTERNAL TABLE usEr (\n\ta int\n)\nWITH (a = \"b\");\n"},
391395
{"creAte exTernAl TabLe iF NOt Exists usEr (a int) With (a = \"b\")",
392396
"CREATE EXTERNAL TABLE IF NOT EXISTS usEr (\n\ta int\n)\nWITH (a = \"b\");\n"},
393397
{"create external table user (a int) with (a=\"b\",c=\"d\")",

ydb/library/yql/sql/v1/sql_query.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ bool TSqlQuery::Statement(TVector<TNodePtr>& blocks, const TRule_sql_stmt_core&
184184

185185
if (replaceIfExists && tableType != ETableType::ExternalTable) {
186186
Context().Error(GetPos(rule.GetBlock2().GetToken1()))
187-
<< "OR REPLACE is supported only for EXTERNAL DATA SOURCE and EXTERNAL TABLE";
187+
<< "OR REPLACE feature is supported only for EXTERNAL DATA SOURCE and EXTERNAL TABLE";
188188
return false;
189189
}
190190

ydb/library/yql/sql/v1/sql_ut.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -5606,6 +5606,26 @@ Y_UNIT_TEST_SUITE(ExternalDataSource) {
56065606
UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write"]);
56075607
}
56085608

5609+
Y_UNIT_TEST(CreateOrReplaceForUnsupportedTableTypesShouldFail) {
5610+
ExpectFailWithError(R"sql(
5611+
USE plato;
5612+
CREATE OR REPLACE TABLE t (a int32 not null, primary key(a, a));
5613+
)sql" , "<main>:3:23: Error: OR REPLACE feature is supported only for EXTERNAL DATA SOURCE and EXTERNAL TABLE\n");
5614+
5615+
ExpectFailWithError(R"sql(
5616+
USE plato;
5617+
CREATE OR REPLACE TABLE t (
5618+
Key Uint64,
5619+
Value1 String,
5620+
PRIMARY KEY (Key)
5621+
)
5622+
WITH (
5623+
STORE = COLUMN,
5624+
AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 10
5625+
);
5626+
)sql" , "<main>:3:23: Error: OR REPLACE feature is supported only for EXTERNAL DATA SOURCE and EXTERNAL TABLE\n");
5627+
}
5628+
56095629
Y_UNIT_TEST(CreateExternalDataSourceWithBadArguments) {
56105630
ExpectFailWithError(R"sql(
56115631
USE plato;

0 commit comments

Comments
 (0)