Skip to content

Commit

Permalink
[test](doc) add some update-example in doris's doc to regression test (
Browse files Browse the repository at this point in the history
  • Loading branch information
yagagagaga authored Nov 11, 2024
1 parent 279c162 commit a5c713f
Show file tree
Hide file tree
Showing 9 changed files with 279 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
1 2020-02-22 1 2020-03-05 c

-- !sql --
1 2020-02-22 1 2020-03-05 c

-- !sql --
1 2020-02-22 1 2020-03-23 w

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
1 100.000000000 To be shipped

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
1 100.000000000 To be shipped

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.

import org.junit.jupiter.api.Assertions;

suite("docs/data-operate/update/unique-update-transaction.md") {
def writeToFile = {String path, String data ->
OutputStreamWriter w = null
try {
w = new OutputStreamWriter(new FileOutputStream(path))
w.write(data)
w.flush()
w.close()
} finally {
if (w != null) w.close()
}
}
try {
multi_sql """
CREATE DATABASE IF NOT EXISTS test; USE test;
DROP TABLE IF EXISTS test.test_table;
CREATE TABLE test.test_table
(
user_id bigint,
date date,
group_id bigint,
modify_date date,
keyword VARCHAR(128)
)
UNIQUE KEY(user_id, date, group_id)
DISTRIBUTED BY HASH (user_id) BUCKETS 32
PROPERTIES(
"function_column.sequence_col" = 'modify_date',
"replication_num" = "1",
"in_memory" = "false"
);
"""
sql "desc test_table;"
writeToFile("${context.file.parent}/testData", """\
1 2020-02-22 1 2020-02-21 a
1 2020-02-22 1 2020-02-22 b
1 2020-02-22 1 2020-03-05 c
1 2020-02-22 1 2020-02-26 d
1 2020-02-22 1 2020-02-23 e
1 2020-02-22 1 2020-02-24 b
""")
cmd """curl --location-trusted -u ${context.config.jdbcUser}:${context.config.jdbcPassword} -T ${context.file.parent}/testData http://${context.config.feHttpAddress}/api/test/test_table/_stream_load"""
qt_sql "select * from test_table;"

writeToFile("${context.file.parent}/testData", """\
1 2020-02-22 1 2020-02-22 a
1 2020-02-22 1 2020-02-23 b
""")
cmd """curl --location-trusted -u ${context.config.jdbcUser}:${context.config.jdbcPassword} -T ${context.file.parent}/testData http://${context.config.feHttpAddress}/api/test/test_table/_stream_load"""
qt_sql "select * from test_table;"

writeToFile("${context.file.parent}/testData", """\
1 2020-02-22 1 2020-02-22 a
1 2020-02-22 1 2020-03-23 w
""")
cmd """curl --location-trusted -u ${context.config.jdbcUser}:${context.config.jdbcPassword} -T ${context.file.parent}/testData http://${context.config.feHttpAddress}/api/test/test_table/_stream_load"""
qt_sql "select * from test_table;"

} catch (Throwable t) {
Assertions.fail("examples in docs/data-operate/update/unique-update-transaction.md failed to exec, please fix it", t)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.

import org.junit.jupiter.api.Assertions;

suite("docs/data-operate/update/unique-update.md") {
try {
multi_sql """
DROP TABLE IF EXISTS test_order;
CREATE TABLE IF NOT EXISTS test_order
(
`order_id` BIGINT NOT NULL,
`order_amount` DECIMAL(27, 9) NOT NULL,
`order_status` VARCHAR(65533)
)
UNIQUE KEY(`order_id`)
DISTRIBUTED BY HASH(`order_id`) BUCKETS 1
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
INSERT INTO test_order(order_id, order_amount, order_status) VALUES
(1 , 100 , 'Pending' );
"""
sql """UPDATE test_order SET order_status = 'To be shipped' WHERE order_id = 1;"""
qt_sql "SELECT * FROM test_order"
} catch (Throwable t) {
Assertions.fail("examples in docs/data-operate/update/unique-update.md failed to exec, please fix it", t)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.

import org.junit.jupiter.api.Assertions;

suite("docs/data-operate/update/update-of-aggregate-model.md", "p0,nonConcurrent") {
try {
multi_sql """
DROP TABLE IF EXISTS order_tbl;
CREATE TABLE order_tbl (
order_id int(11) NULL,
order_amount int(11) REPLACE_IF_NOT_NULL NULL,
order_status varchar(100) REPLACE_IF_NOT_NULL NULL
) ENGINE=OLAP
AGGREGATE KEY(order_id)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(order_id) BUCKETS 1
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
INSERT INTO order_tbl(order_id, order_amount, order_status) VALUES
(1 , 100 , 'Pending' );
"""

cmd """curl --location-trusted -u ${context.config.jdbcUser}:${context.config.jdbcPassword} -H "column_separator:," -H "columns:order_id,order_status" -T ${context.file.parent}/update.csv http://${context.config.feHttpAddress}/api/${curDbName}/order_tbl/_stream_load"""
sql """INSERT INTO order_tbl (order_id, order_status) values (1,'Delivery Pending');"""
} catch (Throwable t) {
Assertions.fail("examples in docs/data-operate/update/update-of-aggregate-model.md failed to exec, please fix it", t)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.

import org.junit.jupiter.api.Assertions;

suite("docs/data-operate/update/update-of-unique-model.md") {
try {
multi_sql """
DROP TABLE IF EXISTS order_tbl;
CREATE TABLE IF NOT EXISTS order_tbl
(
`order_id` BIGINT NOT NULL,
`order_amount` DECIMAL(27, 9) NOT NULL,
`order_status` VARCHAR(65533)
)
UNIQUE KEY(`order_id`)
DISTRIBUTED BY HASH(`order_id`) BUCKETS 1
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
INSERT INTO order_tbl(order_id, order_amount, order_status) VALUES
(1 , 100 , 'Pending' );
"""
cmd """curl --location-trusted -u ${context.config.jdbcUser}:${context.config.jdbcPassword} -H "partial_columns:true" -H "column_separator:," -H "columns:order_id,order_status" -T ${context.file.parent}/update.csv http://${context.config.feHttpAddress}/api/${curDbName}/order_tbl/_stream_load"""
multi_sql """
set enable_unique_key_partial_update=true;
INSERT INTO order_tbl (order_id, order_status) values (1,'To be shipped');
"""
qt_sql "SELECT * FROM order_tbl"
} catch (Throwable t) {
Assertions.fail("examples in docs/data-operate/update/update-of-unique-model.md failed to exec, please fix it", t)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.

import org.junit.jupiter.api.Assertions;

suite("docs/data-operate/update/update-overview.md") {
try {
multi_sql """
DROP TABLE IF EXISTS example_tbl_unique_merge_on_write;
CREATE TABLE IF NOT EXISTS example_tbl_unique_merge_on_write
(
`user_id` LARGEINT NOT NULL,
`username` VARCHAR(50) NOT NULL ,
`city` VARCHAR(20),
`age` SMALLINT,
`sex` TINYINT,
`phone` LARGEINT,
`address` VARCHAR(500),
`register_time` DATETIME
)
UNIQUE KEY(`user_id`, `username`)
DISTRIBUTED BY HASH(`user_id`) BUCKETS 1
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"enable_unique_key_merge_on_write" = "true"
);
"""
} catch (Throwable t) {
Assertions.fail("examples in docs/data-operate/update/update-overview.md failed to exec, please fix it", t)
}
}
1 change: 1 addition & 0 deletions regression-test/suites/doc/data-operate/update/update.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1,To be shipped

0 comments on commit a5c713f

Please sign in to comment.