Skip to content

Commit 682e8a6

Browse files
committed
Fixed tests validation
1 parent 908c1b3 commit 682e8a6

File tree

1 file changed

+31
-34
lines changed

1 file changed

+31
-34
lines changed

ydb/library/yql/tests/sql/kqp_yt_file.py

+31-34
Original file line numberDiff line numberDiff line change
@@ -92,101 +92,98 @@
9292
]
9393

9494

95-
def contains_not_commented(sql_query, substr, lower=False):
96-
if lower:
97-
sql_query = sql_query.lower()
98-
count_substr = sql_query.count(substr)
99-
count_substr_commented = sql_query.count('--' + substr) + sql_query.count('-- ' + substr)
100-
return count_substr > count_substr_commented
95+
def contains_insert(sql_query):
96+
sql_query = sql_query.lower()
97+
return sql_query.count('insert into') > sql_query.count('--insert into') + sql_query.count('-- insert into')
10198

10299

103100
def validate_sql(sql_query):
104101
# Unsupported constructions
105-
if contains_not_commented(sql_query, 'define subquery', lower=True):
102+
if 'define subquery' in sql_query.lower():
106103
pytest.skip('SUBQUERY is not supported in KQP')
107104

108-
if contains_not_commented(sql_query, 'insert into', lower=True):
105+
if contains_insert(sql_query):
109106
pytest.skip('INSERT is not supported in KQP')
110107

111-
if contains_not_commented(sql_query, 'discard', lower=True):
108+
if 'discard' in sql_query.lower():
112109
pytest.skip('DISCARD is not supported in KQP')
113110

114-
if contains_not_commented(sql_query, 'evaluate', lower=True):
111+
if 'evaluate' in sql_query.lower():
115112
pytest.skip('EVALUATE is not supported in KQP')
116113

117-
if contains_not_commented(sql_query, 'concat(', lower=True):
114+
if 'concat(' in sql_query.lower():
118115
pytest.skip('CONCAT is not supported in KQP')
119116

120-
if contains_not_commented(sql_query, '.range(', lower=True) or contains_not_commented(sql_query, ' range(', lower=True):
117+
if '.range(' in sql_query.lower() or ' range(' in sql_query.lower():
121118
pytest.skip('RANGE is not supported in KQP')
122119

123-
if contains_not_commented(sql_query, ' each(', lower=True):
120+
if ' each(' in sql_query.lower():
124121
pytest.skip('EACH is not supported in KQP')
125122

126-
if contains_not_commented(sql_query, 'drop table', lower=True):
123+
if 'drop table' in sql_query.lower():
127124
pytest.skip('DROP TABLE is not supported in KQP for extarnal entities')
128125

129-
if contains_not_commented(sql_query, 'sample ', lower=True) or contains_not_commented(sql_query, 'sample(', lower=True):
126+
if 'sample ' in sql_query.lower() or 'sample(' in sql_query.lower():
130127
pytest.skip('SAMPLE is not supported in KQP')
131128

132-
if contains_not_commented(sql_query, 'count(', lower=True):
129+
if 'count(' in sql_query.lower():
133130
pytest.skip('COUNT is not supported in KQP')
134131

135132
# Unsupported functions
136-
if contains_not_commented(sql_query, 'TableName('):
133+
if 'TableName(' in sql_query:
137134
pytest.skip('TableName is not supported in KQP')
138135

139-
if contains_not_commented(sql_query, 'QuoteCode('):
136+
if 'QuoteCode(' in sql_query:
140137
pytest.skip('QuoteCode is not supported in KQP')
141138

142-
if contains_not_commented(sql_query, 'RangeComputeFor('):
139+
if 'RangeComputeFor(' in sql_query:
143140
pytest.skip('RangeComputeFor is not supported in KQP')
144141

145-
if contains_not_commented(sql_query, 'FromBytes('):
142+
if 'FromBytes(' in sql_query:
146143
pytest.skip('FromBytes is not supported in KQP')
147144

148-
if contains_not_commented(sql_query, 'folder(', lower=True):
145+
if 'folder(' in sql_query.lower():
149146
pytest.skip('Folder is not supported in KQP')
150147

151-
if contains_not_commented(sql_query, 'file(', lower=True) or contains_not_commented(sql_query, 'FileContent('):
148+
if 'file(' in sql_query.lower() or 'FileContent(' in sql_query:
152149
pytest.skip('Files is not supported in KQP')
153150

154151
# Unsupported pragmas
155-
if contains_not_commented(sql_query, 'library(', lower=True):
152+
if 'library(' in sql_query.lower():
156153
pytest.skip('Pragma Library is not supported in KQP')
157154

158-
if contains_not_commented(sql_query, 'refselect', lower=True):
155+
if 'refselect' in sql_query.lower():
159156
pytest.skip('Pragma RefSelect is not supported in KQP')
160157

161-
if contains_not_commented(sql_query, 'optimizerflags', lower=True):
158+
if 'optimizerflags' in sql_query.lower():
162159
pytest.skip('Pragma OptimizerFlags is not supported in KQP')
163160

164-
if contains_not_commented(sql_query, 'disablepullupflatmapoverjoin', lower=True):
161+
if 'disablepullupflatmapoverjoin' in sql_query.lower():
165162
pytest.skip('Pragma DisablePullUpFlatMapOverJoin is not supported in KQP')
166163

167-
if contains_not_commented(sql_query, 'costbasedoptimizer', lower=True):
164+
if 'costbasedoptimizer' in sql_query.lower():
168165
pytest.skip('Pragma CostBasedOptimizer is not supported in KQP')
169166

170167
# Unsupported types
171-
if contains_not_commented(sql_query, 'date32', lower=True):
168+
if 'date32' in sql_query.lower():
172169
pytest.skip('Type Date32 is not supported in KQP')
173170

174-
if contains_not_commented(sql_query, 'datetime64', lower=True):
171+
if 'datetime64' in sql_query.lower():
175172
pytest.skip('Type Datetime64 is not supported in KQP')
176173

177-
if contains_not_commented(sql_query, 'timestamp64', lower=True):
174+
if 'timestamp64' in sql_query.lower():
178175
pytest.skip('Type Timestamp64 is not supported in KQP')
179176

180-
if contains_not_commented(sql_query, 'interval64', lower=True):
177+
if 'interval64' in sql_query.lower():
181178
pytest.skip('Type Interval64 is not supported in KQP')
182179

183-
if contains_not_commented(sql_query, 'interval64', lower=True):
180+
if 'interval64' in sql_query.lower():
184181
pytest.skip('Type Interval64 is not supported in KQP')
185182

186-
if contains_not_commented(sql_query, 'void(', lower=True):
183+
if 'void(' in sql_query.lower():
187184
pytest.skip('Type Void is not supported in KQP')
188185

189-
if contains_not_commented(sql_query, 'variant(', lower=True):
186+
if 'variant(' in sql_query.lower():
190187
pytest.skip('Type Variant is not supported in KQP')
191188

192189

0 commit comments

Comments
 (0)