Skip to content

Commit

Permalink
fix(query): missing push binary column (#14342)
Browse files Browse the repository at this point in the history
* fix: missing push binary column

* fix: response for copy
  • Loading branch information
everpcpc authored Jan 16, 2024
1 parent e6541c3 commit 0c540bd
Show file tree
Hide file tree
Showing 31 changed files with 150 additions and 38 deletions.
2 changes: 0 additions & 2 deletions scripts/ci/ci-run-stateless-tests-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ set -e

echo "Starting Cluster databend-query"

# Enable backtrace to debug https://github.com/datafuselabs/databend/issues/7986
export RUST_BACKTRACE=full
./scripts/ci/deploy/databend-query-cluster-3-nodes.sh

SCRIPT_PATH="$(cd "$(dirname "$0")" >/dev/null 2>&1 && pwd)"
Expand Down
4 changes: 4 additions & 0 deletions src/query/expression/src/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,10 @@ impl ColumnBuilder {
(ColumnBuilder::Number(builder), ScalarRef::Number(value)) => builder.push(value),
(ColumnBuilder::Decimal(builder), ScalarRef::Decimal(value)) => builder.push(value),
(ColumnBuilder::Boolean(builder), ScalarRef::Boolean(value)) => builder.push(value),
(ColumnBuilder::Binary(builder), ScalarRef::Binary(value)) => {
builder.put_slice(value);
builder.commit_row();
}
(ColumnBuilder::String(builder), ScalarRef::String(value)) => {
builder.put_slice(value);
builder.commit_row();
Expand Down
1 change: 1 addition & 0 deletions tests/suites/0_stateless/05_hints/05_0001_set_var.result
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ Asia/Shanghai
America/Toronto
2022-02-02 03:00:00
2022-02-01 14:00:00
1 64 300
Asia/Shanghai
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
=== test db/table ===
200
=== test stage ===
1 8 282
0
=== test udf ===
2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ Error: APIError: ResponseError with 1063: Permission denied: User 'a'@'%' does n
7
1
0
1 64 262
Error: APIError: ResponseError with 1063: Permission denied, privilege [Select] is required on 'default'.'default'.'t1' for user 'b'@'%' with roles [public]
Error: APIError: ResponseError with 1063: Permission denied, privilege [Read] is required on STAGE s3 for user 'b'@'%' with roles [public]
Error: APIError: ResponseError with 1063: Permission denied, privilege [Select] is required on 'default'.'default'.'t' for user 'b'@'%' with roles [public]
Error: APIError: ResponseError with 1063: Permission denied, privilege [Read] is required on STAGE s3 for user 'b'@'%' with roles [public]
Error: APIError: ResponseError with 1063: Permission denied, privilege [Read] is required on STAGE s3 for user 'b'@'%' with roles [public]
Error: APIError: ResponseError with 1063: Permission denied, privilege [Select] is required on 'default'.'default'.'t1' for user 'b'@'%' with roles [public]
a b/data_UUID_0000_00000000.parquet 1 0 NULL NULL
=== check db/table_id ===
GRANT CREATE ON 'default'.'default'.* TO 'b'@'%'
GRANT SELECT,INSERT,DELETE ON 'default'.'default'.'t' TO 'b'@'%'
Expand Down
11 changes: 6 additions & 5 deletions tests/suites/0_stateless/18_rbac/20_0012_privilege_access.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)

export TEST_USER_PASSWORD="password"
export TEST_USER_CONNECT="bendsql --user=test-user --password=password --host=${QUERY_MYSQL_HANDLER_HOST} --port ${QUERY_HTTP_HANDLER_PORT}"
export RM_UUID="sed -E ""s/[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}/UUID/g"""

echo "set global enable_experimental_rbac_check=1" | $BENDSQL_CLIENT_CONNECT

Expand Down Expand Up @@ -93,8 +94,8 @@ echo "create database default2" | $BENDSQL_CLIENT_CONNECT

echo "create view default2.v_t20_0012 as select * from default.t20_0012_a" | $BENDSQL_CLIENT_CONNECT
echo "select * from default2.v_t20_0012" | $TEST_USER_CONNECT
## Only grant privilege for view table, now this user can access the view under default2 db,
## but can not access the tables under the `default` database, stil raises permission error
## Only grant privilege for view table, now this user can access the view under default2 db,
## but can not access the tables under the `default` database, stil raises permission error
## on SELECT default2.v_t20_0012
echo "GRANT SELECT ON default2.v_t20_0012 TO 'test-user'" | $BENDSQL_CLIENT_CONNECT
echo "REVOKE SELECT ON default.t20_0012_a FROM 'test-user'" | $BENDSQL_CLIENT_CONNECT
Expand Down Expand Up @@ -189,14 +190,14 @@ echo "grant insert, delete on default.t to b" | $BENDSQL_CLIENT_CONNECT
echo "grant select on system.* to b" | $BENDSQL_CLIENT_CONNECT

echo "create stage s3;" | $BENDSQL_CLIENT_CONNECT
echo "copy into '@s3/a b' from (select 2);" | $BENDSQL_CLIENT_CONNECT
echo "copy into '@s3/a b' from (select 2);" | $BENDSQL_CLIENT_CONNECT | $RM_UUID

# need err
echo "insert into t select * from t1" | $USER_B_CONNECT
echo "insert into t select * from @s3" | $USER_B_CONNECT
echo "create table t2 as select * from t" | $USER_B_CONNECT
echo "create table t2 as select * from @s3" | $USER_B_CONNECT
echo "copy into t from (select * from @s3);" | $USER_B_CONNECT
echo "copy into t from (select * from @s3);" | $USER_B_CONNECT | $RM_UUID
echo "replace into t on(id) select * from t1;" | $USER_B_CONNECT

echo "grant select on default.t to b" | $BENDSQL_CLIENT_CONNECT
Expand All @@ -208,7 +209,7 @@ echo "insert into t select * from @s3" | $USER_B_CONNECT
echo "create table t2 as select * from t" | $USER_B_CONNECT
echo "drop table t2" | $BENDSQL_CLIENT_CONNECT
echo "create table t2 as select * from @s3" | $USER_B_CONNECT
echo "copy into t from (select * from @s3);" | $USER_B_CONNECT
echo "copy into t from (select * from @s3);" | $USER_B_CONNECT | $RM_UUID
echo "replace into t on(id) select * from t1;" | $USER_B_CONNECT

## check after alter table/db name, table id and db id is normal.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
2 10 373
expects .stats.write_progress.rows be 2
expects .error be null
2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
SUCCESS
sample.csv
-- testing copy;
sample.csv 5 0 NULL NULL
5
-- testing copy with purge;
sample.csv 5 0 NULL NULL
5
---- testing @~;
SUCCESS
sample.csv
-- testing copy;
sample.csv 5 0 NULL NULL
5
-- testing copy with purge;
sample.csv 5 0 NULL NULL
5
---- check files are purged;
0
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
20 160 160
20 450 3648
2
20 160 160
2 changes: 2 additions & 0 deletions tests/suites/1_stateful/00_stage/00_0002_copy_purge.result
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
>>>> drop stage if exists s_ii
>>>> create stage s_ii url='fs:///tmp/00_0002/';
>>>> copy into ii from @s_ii file_format = (type = CSV) purge = true
i0.csv 2 0 NULL NULL
<<<<
>>>> list @s_ii
<<<<
Expand All @@ -11,6 +12,7 @@
2 2
>>>> truncate table ii
>>>> copy into ii from @s_ii file_format = (type = CSV) files = ('i1.csv') purge = true
/i1.csv 2 0 NULL NULL
<<<<
>>>> list @s_ii
<<<<
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,46 @@
--- force = false, purge = false
6
f1.parquet 2 0 NULL NULL
f3.parquet 2 0 NULL NULL
4
remain 3 files
f2.parquet 2 0 NULL NULL
6
remain 3 files
6
remain 3 files
--- force = false, purge = true
6
f1.parquet 2 0 NULL NULL
f3.parquet 2 0 NULL NULL
4
remain 1 files
f2.parquet 2 0 NULL NULL
6
remain 0 files
6
remain 0 files
--- force = true, purge = false
6
f1.parquet 2 0 NULL NULL
f3.parquet 2 0 NULL NULL
4
remain 3 files
f1.parquet 2 0 NULL NULL
f3.parquet 2 0 NULL NULL
8
remain 3 files
f1.parquet 2 0 NULL NULL
f3.parquet 2 0 NULL NULL
12
remain 3 files
--- force = true, purge = true
6
f1.parquet 2 0 NULL NULL
f3.parquet 2 0 NULL NULL
4
remain 1 files
f2.parquet 2 0 NULL NULL
6
remain 0 files
6
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,42 @@
--- force = false, purge = false
f1.csv 2 0 NULL NULL
f3.csv 2 0 NULL NULL
4
remain 3 files
f2.csv 2 0 NULL NULL
6
remain 3 files
6
remain 3 files
--- force = false, purge = true
f1.csv 2 0 NULL NULL
f3.csv 2 0 NULL NULL
4
remain 1 files
f2.csv 2 0 NULL NULL
6
remain 0 files
6
remain 0 files
--- force = true, purge = false
f1.csv 2 0 NULL NULL
f3.csv 2 0 NULL NULL
4
remain 3 files
f1.csv 2 0 NULL NULL
f3.csv 2 0 NULL NULL
8
remain 3 files
f1.csv 2 0 NULL NULL
f3.csv 2 0 NULL NULL
12
remain 3 files
--- force = true, purge = true
f1.csv 2 0 NULL NULL
f3.csv 2 0 NULL NULL
4
remain 1 files
f2.csv 2 0 NULL NULL
6
remain 0 files
6
Expand Down
11 changes: 11 additions & 0 deletions tests/suites/1_stateful/00_stage/00_0007_copy_into_stage2.result
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
20 160 160
---csv
1
20
20 160 160
---csv_single
1
20
20 160 160
---csv_10
10
20
20 160 160
---csv_20
5
20
20 450 3648
---parq
1
20
20 450 3648
---parq_single
1
20
20 450 5160
---parq_40
10
20
20 450 4320
---parq_80
5
20
big.csv 2000 0 NULL NULL
2000 8893 8893
---csv_big_20
2
2000
2000 8250 4599
---parq_big_80
1
2000
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ null
null
null
null
itt.csv 5 0 NULL NULL
sample.csv 6 0 NULL NULL
sample_3_duplicate.csv 8 0 NULL NULL
sample_3_replace.csv 5 0 NULL NULL
1 'Beijing' 100
1 'Beijing' 100
1 'Chengdu' 80
Expand Down Expand Up @@ -32,5 +36,10 @@ Error: APIError: ResponseError with 1046: Number of columns in file (2) does not
at file 'sample_2_columns.csv', line 0
24
5
itt.csv 5 0 NULL NULL
sample.csv 6 0 NULL NULL
sample_2_columns.csv 6 0 NULL NULL
sample_3_duplicate.csv 8 0 NULL NULL
sample_3_replace.csv 5 0 NULL NULL
54
0
6 changes: 6 additions & 0 deletions tests/suites/1_stateful/00_stage/00_0012_stage_priv.result
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
==== check internal stage write priv ===
Error: APIError: ResponseError with 1063: Permission denied, privilege [Write] is required on STAGE s2 for user 'u1'@'%' with roles [public]
Error: APIError: ResponseError with 1063: Permission denied, privilege [Select] is required on 'default'.'default'.'test_table' for user 'u1'@'%' with roles [public]
20 160 160
1
==== check external stage priv ===
Error: APIError: ResponseError with 1063: Permission denied, privilege [Write] is required on STAGE s1 for user 'u1'@'%' with roles [public]
20 160 160
Error: APIError: ResponseError with 1063: Permission denied, privilege [Read] is required on STAGE s1 for user 'u1'@'%' with roles [public]
csv/data_UUID_0000_00000000.csv 20 0 NULL NULL
==== check internal stage read priv ===
Error: APIError: ResponseError with 1063: Permission denied, privilege [Read] is required on STAGE s2 for user 'u1'@'%' with roles [public]
data_UUID_0000_00000000.csv 20 0 NULL NULL
=== check presign ===
Error: APIError: ResponseError with 1063: Permission denied, privilege [Write] is required on STAGE presign_stage for user 'u1'@'%' with roles [public]
000
Error: APIError: ResponseError with 1063: Permission denied, privilege [Read] is required on STAGE presign_stage for user 'u1'@'%' with roles [public]
000
Error: APIError: ResponseError with 1063: Permission denied, privilege [Write] is required on STAGE s3 for user 'u1'@'%' with roles [public]
1 64 262
Error: APIError: ResponseError with 1063: Permission denied, privilege [Read] is required on STAGE s3 for user 'u1'@'%' with roles [public]
Error: APIError: ResponseError with 1063: Permission denied, privilege READ is required on stage s3 for user 'u1'@'%'
Error: APIError: ResponseError with 1063: Permission denied, privilege READ is required on stage s3 for user 'u1'@'%'
Expand All @@ -24,6 +29,7 @@ Error: APIError: ResponseError with 1063: Permission denied, privilege READ is r
=== check external location ===
1 1
2 2
i0.csv 2 0 NULL NULL
1 1
2 2
=== check access user's local stage ===
Loading

0 comments on commit 0c540bd

Please sign in to comment.