-
Notifications
You must be signed in to change notification settings - Fork 757
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
275 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ mod background_service; | |
mod inverted_index; | ||
mod license; | ||
mod storages; | ||
mod stream; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2023 Databend Cloud | ||
// | ||
// Licensed under the Elastic License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.elastic.co/licensing/elastic-license | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
mod stream_create; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright 2023 Databend Cloud | ||
// | ||
// Licensed under the Elastic License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.elastic.co/licensing/elastic-license | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use chrono::Duration; | ||
use chrono::Utc; | ||
use databend_common_base::base::tokio; | ||
use databend_common_exception::Result; | ||
use databend_enterprise_query::test_kits::context::EESetup; | ||
use databend_query::test_kits::generate_snapshots; | ||
use databend_query::test_kits::TestFixture; | ||
|
||
#[tokio::test(flavor = "multi_thread")] | ||
async fn test_stream_create() -> Result<()> { | ||
let fixture = TestFixture::setup_with_custom(EESetup::new()).await?; | ||
fixture.create_default_database().await?; | ||
fixture.create_normal_table().await?; | ||
|
||
let db = fixture.default_db_name(); | ||
let tbl = fixture.default_table_name(); | ||
{ | ||
let qry = format!( | ||
"alter table {}.{} set options(change_tracking=true)", | ||
db, tbl | ||
); | ||
let r = fixture.execute_command(&qry).await; | ||
assert!(r.is_ok()); | ||
} | ||
|
||
generate_snapshots(&fixture).await?; | ||
let now = Utc::now(); | ||
{ | ||
let time_point = now - Duration::hours(14); | ||
let qry = format!( | ||
"create stream s on table {}.{} at(timestamp => '{:?}'::TIMESTAMP)", | ||
db, tbl, time_point | ||
); | ||
let r = fixture.execute_command(&qry).await; | ||
assert!(r.is_err()); | ||
let expect = "TableHistoricalDataNotFound. Code: 2013, Text = No historical data found at given point."; | ||
assert_eq!(expect, format!("{}", r.unwrap_err())); | ||
} | ||
|
||
{ | ||
let time_point = now - Duration::hours(12); | ||
let qry = format!( | ||
"create stream s on table {}.{} at(timestamp => '{:?}'::TIMESTAMP)", | ||
db, tbl, time_point | ||
); | ||
let r = fixture.execute_command(&qry).await; | ||
assert!(r.is_err()); | ||
let expect = "IllegalStream. Code: 2733, Text = The stream navigation at point has not table version."; | ||
assert_eq!(expect, format!("{}", r.unwrap_err())); | ||
} | ||
|
||
{ | ||
let qry = format!( | ||
"create stream s on table {}.{} append_only = false", | ||
db, tbl | ||
); | ||
let r = fixture.execute_command(&qry).await; | ||
assert!(r.is_ok()); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Error: APIError: ResponseError with 2733: Change tracking has been missing for the time range requested on table 'db_stream.base' | ||
3 INSERT false true | ||
Error: APIError: ResponseError with 2733: Change tracking has been missing for the time range requested on table 'db_stream.base' | ||
3 INSERT false true | ||
Error: APIError: ResponseError with 2733: Change tracking has been missing for the time range requested on table 'db_stream.base' | ||
Error: APIError: ResponseError with 2733: Change tracking has been missing for the time range requested on table 'db_stream.base' | ||
Error: APIError: ResponseError with 2733: Change tracking has been missing for the time range requested on table 'db_stream.base' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
|
||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | ||
. "$CURDIR"/../../../shell_env.sh | ||
|
||
echo "drop database if exists db_stream" | $BENDSQL_CLIENT_CONNECT | ||
echo "create database db_stream" | $BENDSQL_CLIENT_CONNECT | ||
echo "create table db_stream.base(a int)" | $BENDSQL_CLIENT_CONNECT | ||
echo "insert into db_stream.base values(1)" | $BENDSQL_CLIENT_CONNECT | ||
echo "alter table db_stream.base set options(change_tracking = true)" | $BENDSQL_CLIENT_CONNECT | ||
echo "insert into db_stream.base values(2)" | $BENDSQL_CLIENT_CONNECT | ||
echo "insert into db_stream.base values(3)" | $BENDSQL_CLIENT_CONNECT | ||
|
||
BASE_ROW_ID=$(echo "select _base_row_id from db_stream.base where a = 3" | $BENDSQL_CLIENT_CONNECT) | ||
|
||
SNAPSHOT_ID_1=$(echo "select snapshot_id from fuse_snapshot('db_stream','base') where row_count=1 limit 1" | $BENDSQL_CLIENT_CONNECT) | ||
echo "create stream db_stream.s1 on table db_stream.base at (snapshot => '$SNAPSHOT_ID_1')" | $BENDSQL_CLIENT_CONNECT | ||
|
||
SNAPSHOT_ID_2=$(echo "select snapshot_id from fuse_snapshot('db_stream','base') where row_count=2 limit 1" | $BENDSQL_CLIENT_CONNECT) | ||
echo "create stream db_stream.s2 on table db_stream.base at (snapshot => '$SNAPSHOT_ID_2')" | $BENDSQL_CLIENT_CONNECT | ||
echo "select a, change\$action, change\$is_update, change\$row_id='$BASE_ROW_ID' from db_stream.s2" | $BENDSQL_CLIENT_CONNECT | ||
|
||
TIMEPOINT_1=$(echo "select timestamp from fuse_snapshot('db_stream','base') where row_count=1 limit 1" | $BENDSQL_CLIENT_CONNECT) | ||
echo "create stream db_stream.t1 on table db_stream.base at (timestamp => '$TIMEPOINT_1'::TIMESTAMP)" | $BENDSQL_CLIENT_CONNECT | ||
|
||
echo "alter table db_stream.base set options(change_tracking = true)" | $BENDSQL_CLIENT_CONNECT | ||
TIMEPOINT_2=$(echo "select timestamp from fuse_snapshot('db_stream','base') where row_count=2 limit 1" | $BENDSQL_CLIENT_CONNECT) | ||
echo "create stream db_stream.t2 on table db_stream.base at (timestamp => '$TIMEPOINT_2'::TIMESTAMP)" | $BENDSQL_CLIENT_CONNECT | ||
echo "select a, change\$action, change\$is_update, change\$row_id='$BASE_ROW_ID' from db_stream.t2" | $BENDSQL_CLIENT_CONNECT | ||
|
||
echo "alter table db_stream.base set options(change_tracking = false)" | $BENDSQL_CLIENT_CONNECT | ||
echo "create stream db_stream.s3 on table db_stream.base at (snapshot => '$SNAPSHOT_ID_2')" | $BENDSQL_CLIENT_CONNECT | ||
echo "alter table db_stream.base set options(change_tracking = true)" | $BENDSQL_CLIENT_CONNECT | ||
echo "create stream db_stream.s4 on table db_stream.base at (stream => db_stream.s2)" | $BENDSQL_CLIENT_CONNECT | ||
echo "select a from db_stream.s2" | $BENDSQL_CLIENT_CONNECT | ||
|
||
echo "drop stream if exists db_stream.s2" | $BENDSQL_CLIENT_CONNECT | ||
echo "drop stream if exists db_stream.t2" | $BENDSQL_CLIENT_CONNECT | ||
echo "drop table if exists db_stream.base all" | $BENDSQL_CLIENT_CONNECT | ||
echo "drop database if exists db_stream" | $BENDSQL_CLIENT_CONNECT |
2 changes: 1 addition & 1 deletion
2
tests/suites/7_management/00_stream_status/00_0000_stream_status.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
true | ||
false | ||
false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters