-
Notifications
You must be signed in to change notification settings - Fork 591
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(sink): add deltalake-sink compatible test (#16448)
- Loading branch information
Showing
9 changed files
with
96 additions
and
22 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -40,4 +40,4 @@ volumes: | |
external: false | ||
prometheus-0: | ||
external: false | ||
name: risingwave-compose | ||
name: risingwave-compose |
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 |
---|---|---|
@@ -1,30 +1,35 @@ | ||
import subprocess | ||
from time import sleep | ||
|
||
sleep(60) | ||
def run_query(file): | ||
with open(query_output_file_name, 'w') as f: | ||
subprocess.run( | ||
["docker", "compose", "exec", "spark", "bash", "/spark-script/run-sql-file.sh", file], | ||
check=True, stdout=f) | ||
|
||
|
||
|
||
query_sql = open("spark-script/query-table.sql").read() | ||
|
||
print("querying deltalake with sql: %s" % query_sql) | ||
|
||
query_output_file_name = "query_output.txt" | ||
|
||
query_output_file = open(query_output_file_name, "wb") | ||
|
||
subprocess.run( | ||
["docker", "compose", "exec", "spark", "bash", "/spark-script/run-sql-file.sh", "query-table"], | ||
check=True, stdout=query_output_file) | ||
query_output_file.close() | ||
|
||
run_query('query-table') | ||
with open(query_output_file_name, 'r') as file: | ||
all_lines = file.readlines() | ||
last_three_lines = all_lines[-3:] | ||
|
||
last_three_lines = all_lines[-3:] | ||
|
||
print("result", last_three_lines) | ||
print("result", last_three_lines) | ||
line1, line2, line3 = last_three_lines | ||
assert line1.strip() == '1\ta' | ||
assert line2.strip() == '2\tb' | ||
assert line3.strip() == '3\tc' | ||
|
||
line1, line2, line3 = last_three_lines | ||
|
||
assert line1.strip() == '1\ta' | ||
assert line2.strip() == '2\tb' | ||
assert line3.strip() == '3\tc' | ||
run_query('data-types-query') | ||
with open(query_output_file_name, 'r') as f: | ||
all_lines = f.readlines() | ||
last_line = all_lines[-1] | ||
print("rows of data_types: ", last_line) | ||
assert last_line.strip() == '3' |
27 changes: 26 additions & 1 deletion
27
integration_tests/deltalake-sink/spark-script/create-table.sql
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 +1,26 @@ | ||
create table delta.`s3a://deltalake/delta`(id int, name string) using delta | ||
create table delta.`s3a://deltalake/delta`(id int, name string) using delta; | ||
|
||
create table delta.`s3a://deltalake/data_types`( | ||
types_id INT, | ||
c_boolean boolean, | ||
c_smallint short, | ||
c_integer integer, | ||
c_bigint long, | ||
c_decimal decimal(28), | ||
c_real float, | ||
c_double_precision double, | ||
c_varchar string, | ||
c_date date, | ||
c_timestamptz timestamp, | ||
c_boolean_array ARRAY<boolean>, | ||
c_smallint_array ARRAY<short>, | ||
c_integer_array ARRAY<integer>, | ||
c_bigint_array ARRAY<long>, | ||
c_decimal_array ARRAY<decimal(28)>, | ||
c_real_array ARRAY<float>, | ||
c_double_precision_array ARRAY<double>, | ||
c_varchar_array ARRAY<string>, | ||
c_date_array ARRAY<date>, | ||
c_timestamptz_array ARRAY<timestamp>, | ||
c_struct STRUCT<s_int:INTEGER, s_varchar:string> | ||
) using delta; |
1 change: 1 addition & 0 deletions
1
integration_tests/deltalake-sink/spark-script/data-types-query.sql
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 @@ | ||
SELECT count(*) from delta.`s3a://deltalake/data_types`; |
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 +1 @@ | ||
SELECT * from delta.`s3a://deltalake/delta` order by id; | ||
SELECT * from delta.`s3a://deltalake/delta` order by id; |
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