11
11
from google .protobuf import text_format
12
12
from yql_utils import execute_sql , get_supported_providers , get_tables , get_files , get_http_files , \
13
13
get_pragmas , log , KSV_ATTR , is_xfail , get_param , YQLExecResult , yql_binary_path
14
+ from kqprun import KqpRun
14
15
from yqlrun import YQLRun
15
16
16
17
from utils import get_config , get_parameters_json , DATA_PATH
@@ -41,7 +42,11 @@ def get_gateways_config(http_files, yql_http_file_server, force_blocks=False, is
41
42
return config
42
43
43
44
44
- def run_file_no_cache (provider , suite , case , cfg , config , yql_http_file_server , yqlrun_binary = None , extra_args = [], force_blocks = False ):
45
+ def is_hybrid (provider ):
46
+ return provider == 'hybrid'
47
+
48
+
49
+ def get_sql_query (provider , suite , case , config ):
45
50
if provider not in get_supported_providers (config ):
46
51
pytest .skip ('%s provider is not supported here' % provider )
47
52
@@ -51,30 +56,37 @@ def run_file_no_cache(provider, suite, case, cfg, config, yql_http_file_server,
51
56
if "yson" in case or "regexp" in case or "match" in case :
52
57
pytest .skip ('yson/match/regexp is not supported on non-default target platform' )
53
58
54
- xfail = is_xfail (config )
55
- if get_param ('TARGET_PLATFORM' ) and xfail :
59
+ if get_param ('TARGET_PLATFORM' ) and is_xfail (config ):
56
60
pytest .skip ('xfail is not supported on non-default target platform' )
57
61
58
- in_tables , out_tables = get_tables (suite , config , DATA_PATH , def_attr = KSV_ATTR )
59
- files = get_files (suite , config , DATA_PATH )
60
- http_files = get_http_files (suite , config , DATA_PATH )
61
- http_files_urls = yql_http_file_server .register_files ({}, http_files )
62
-
63
62
program_sql = os .path .join (DATA_PATH , suite , '%s.sql' % case )
64
- is_hybrid = provider == 'hybrid'
65
63
66
64
with codecs .open (program_sql , encoding = 'utf-8' ) as program_file_descr :
67
65
sql_query = program_file_descr .read ()
68
66
if get_param ('TARGET_PLATFORM' ):
69
67
if "Yson::" in sql_query :
70
68
pytest .skip ('yson udf is not supported on non-default target platform' )
71
- if (provider + 'file can not' in sql_query ) or (is_hybrid and ('ytfile can not' in sql_query )):
69
+ if (provider + 'file can not' in sql_query ) or (is_hybrid ( provider ) and ('ytfile can not' in sql_query )):
72
70
pytest .skip (provider + ' can not execute this' )
73
71
74
72
pragmas .append (sql_query )
75
73
sql_query = ';\n ' .join (pragmas )
76
74
if 'Python' in sql_query or 'Javascript' in sql_query :
77
75
pytest .skip ('ScriptUdf' )
76
+
77
+ return sql_query
78
+
79
+
80
+ def run_file_no_cache (provider , suite , case , cfg , config , yql_http_file_server , yqlrun_binary = None , extra_args = [], force_blocks = False ):
81
+ sql_query = get_sql_query (provider , suite , case , config )
82
+
83
+ xfail = is_xfail (config )
84
+
85
+ in_tables , out_tables = get_tables (suite , config , DATA_PATH , def_attr = KSV_ATTR )
86
+ files = get_files (suite , config , DATA_PATH )
87
+ http_files = get_http_files (suite , config , DATA_PATH )
88
+ http_files_urls = yql_http_file_server .register_files ({}, http_files )
89
+
78
90
for table in in_tables :
79
91
if cyson .loads (table .attr ).get ("type" ) == "document" :
80
92
content = table .content
@@ -89,7 +101,7 @@ def run_file_no_cache(provider, suite, case, cfg, config, yql_http_file_server,
89
101
prov = provider ,
90
102
keep_temp = not re .search (r"yt\.ReleaseTempData" , sql_query ),
91
103
binary = yqlrun_binary ,
92
- gateway_config = get_gateways_config (http_files , yql_http_file_server , force_blocks = force_blocks , is_hybrid = is_hybrid ),
104
+ gateway_config = get_gateways_config (http_files , yql_http_file_server , force_blocks = force_blocks , is_hybrid = is_hybrid ( provider ) ),
93
105
extra_args = extra_args ,
94
106
udfs_dir = yql_binary_path ('ydb/library/yql/tests/common/test_framework/udfs_deps' )
95
107
)
@@ -129,11 +141,40 @@ def run_file_no_cache(provider, suite, case, cfg, config, yql_http_file_server,
129
141
return fixed_result , tables_res
130
142
131
143
144
+ def run_file_kqp_no_cache (suite , case , cfg ):
145
+ config = get_config (suite , case , cfg )
146
+
147
+ if is_xfail (config ):
148
+ pytest .skip ('skip fail tests' )
149
+
150
+ sql_query = get_sql_query ('yt' , suite , case , config )
151
+ in_tables = get_tables (suite , config , DATA_PATH , def_attr = KSV_ATTR )[0 ]
152
+
153
+ kqprun = KqpRun (
154
+ udfs_dir = yql_binary_path ('ydb/library/yql/tests/common/test_framework/udfs_deps' )
155
+ )
156
+
157
+ return kqprun .yql_exec (
158
+ program = sql_query ,
159
+ verbose = True ,
160
+ check_error = True ,
161
+ tables = in_tables
162
+ )
163
+
164
+
132
165
def run_file (provider , suite , case , cfg , config , yql_http_file_server , yqlrun_binary = None , extra_args = [], force_blocks = False ):
133
166
if (suite , case , cfg ) not in run_file .cache :
134
167
run_file .cache [(suite , case , cfg )] = run_file_no_cache (provider , suite , case , cfg , config , yql_http_file_server , yqlrun_binary , extra_args , force_blocks = force_blocks )
135
168
136
169
return run_file .cache [(suite , case , cfg )]
137
170
138
171
172
+ def run_file_kqp (suite , case , cfg ):
173
+ if (suite , case , cfg ) not in run_file_kqp .cache :
174
+ run_file_kqp .cache [(suite , case , cfg )] = run_file_kqp_no_cache (suite , case , cfg )
175
+
176
+ return run_file_kqp .cache [(suite , case , cfg )]
177
+
178
+
139
179
run_file .cache = {}
180
+ run_file_kqp .cache = {}
0 commit comments