|
|
@ -18,9 +18,12 @@ |
|
|
|
import io |
|
|
|
import io |
|
|
|
from datetime import datetime |
|
|
|
from datetime import datetime |
|
|
|
|
|
|
|
|
|
|
|
from minio.select.options import (CSVInput, CSVOutput, InputSerialization, |
|
|
|
from minio.selectrequest import (FILE_HEADER_INFO_NONE, JSON_TYPE_DOCUMENT, |
|
|
|
JSONInput, JSONOutput, OutputSerialization, |
|
|
|
QUOTE_FIELDS_ASNEEDED, CSVInputSerialization, |
|
|
|
RequestProgress, SelectObjectOptions) |
|
|
|
CSVOutputSerialization, |
|
|
|
|
|
|
|
JSONInputSerialization, |
|
|
|
|
|
|
|
JSONOutputSerialization, SelectRequest) |
|
|
|
|
|
|
|
|
|
|
|
from utils import generate_bucket_name, generate_object_name |
|
|
|
from utils import generate_bucket_name, generate_object_name |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -42,17 +45,15 @@ def test_sql_expressions_custom_input_output(client, input_bytes, sql_input, |
|
|
|
continue |
|
|
|
continue |
|
|
|
try: |
|
|
|
try: |
|
|
|
log_output.args['total_tests'] += 1 |
|
|
|
log_output.args['total_tests'] += 1 |
|
|
|
options = SelectObjectOptions( |
|
|
|
sreq = SelectRequest( |
|
|
|
expression=select_expression, |
|
|
|
select_expression, |
|
|
|
input_serialization=sql_input, |
|
|
|
sql_input, |
|
|
|
output_serialization=sql_output, |
|
|
|
sql_output, |
|
|
|
request_progress=RequestProgress( |
|
|
|
request_progress=False |
|
|
|
enabled="False" |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
data = client.select_object_content( |
|
|
|
data = client.select_object_content( |
|
|
|
bucket_name, object_name, options) |
|
|
|
bucket_name, object_name, sreq) |
|
|
|
|
|
|
|
|
|
|
|
# Get the records |
|
|
|
# Get the records |
|
|
|
records = io.BytesIO() |
|
|
|
records = io.BytesIO() |
|
|
@ -79,14 +80,13 @@ def test_sql_expressions_custom_input_output(client, input_bytes, sql_input, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_sql_expressions(client, input_json_bytes, tests, log_output): |
|
|
|
def test_sql_expressions(client, input_json_bytes, tests, log_output): |
|
|
|
input_serialization = InputSerialization( |
|
|
|
input_serialization = JSONInputSerialization( |
|
|
|
compression_type="NONE", |
|
|
|
compression_type="NONE", |
|
|
|
json=JSONInput(json_type="DOCUMENT"), |
|
|
|
json_type=JSON_TYPE_DOCUMENT, |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
output_serialization = OutputSerialization( |
|
|
|
output_serialization = CSVOutputSerialization( |
|
|
|
csv=CSVOutput(quote_fields="ASNEEDED") |
|
|
|
quote_fields=QUOTE_FIELDS_ASNEEDED) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_sql_expressions_custom_input_output(client, input_json_bytes, |
|
|
|
test_sql_expressions_custom_input_output(client, input_json_bytes, |
|
|
|
input_serialization, output_serialization, tests, log_output) |
|
|
|
input_serialization, output_serialization, tests, log_output) |
|
|
@ -392,8 +392,8 @@ def test_sql_select_json(client, log_output): |
|
|
|
"Select s.rules[1].expr from S3Object s", b'{"expr":"y > x"}\n{}\n'), |
|
|
|
"Select s.rules[1].expr from S3Object s", b'{"expr":"y > x"}\n{}\n'), |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
input_serialization = InputSerialization(json=JSONInput(json_type="DOCUMENT")) |
|
|
|
input_serialization = JSONInputSerialization(json_type=JSON_TYPE_DOCUMENT) |
|
|
|
output_serialization = OutputSerialization(json=JSONOutput()) |
|
|
|
output_serialization = JSONOutputSerialization() |
|
|
|
try: |
|
|
|
try: |
|
|
|
test_sql_expressions_custom_input_output(client, json_testcontent, |
|
|
|
test_sql_expressions_custom_input_output(client, json_testcontent, |
|
|
|
input_serialization, output_serialization, tests, log_output) |
|
|
|
input_serialization, output_serialization, tests, log_output) |
|
|
@ -414,14 +414,11 @@ val4,val5,val6 |
|
|
|
("select_1", "SELECT s._2 FROM S3Object as s", b'val2\nval5\n'), |
|
|
|
("select_1", "SELECT s._2 FROM S3Object as s", b'val2\nval5\n'), |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
input_serialization = InputSerialization( |
|
|
|
input_serialization = CSVInputSerialization( |
|
|
|
csv=CSVInput( |
|
|
|
file_header_info=FILE_HEADER_INFO_NONE, |
|
|
|
file_header_info="NONE", |
|
|
|
allow_quoted_record_delimiter="FALSE", |
|
|
|
allow_quoted_record_delimiter="FALSE", |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
output_serialization = CSVOutputSerialization() |
|
|
|
output_serialization = OutputSerialization(csv=CSVOutput()) |
|
|
|
|
|
|
|
try: |
|
|
|
try: |
|
|
|
test_sql_expressions_custom_input_output(client, json_testcontent, |
|
|
|
test_sql_expressions_custom_input_output(client, json_testcontent, |
|
|
|
input_serialization, output_serialization, tests, log_output) |
|
|
|
input_serialization, output_serialization, tests, log_output) |
|
|
|