Skip to content

Commit 6339625

Browse files
sander-goossusodapop
authored andcommitted
Enable thrift-dbr-tests for dbsql v4 client
Enable thrift-dbr tests for the new Thrift v4 dbsql python client. - Fix regex for error messages - Enable sharding for sqlquery tests - Remove pyodbc installation - Change launcher script so it can take a parameter for the docker image binary loader
1 parent 76695ea commit 6339625

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Thrift-dbr-test-classes
2+
3+
The classes defined in this folder depend on base classes defined in runtime.
4+
(sql/hive-thriftserver/pythontesting/) They are to be combined in the test-docker-image, see e.g. //cmdexec/client/dbsql-test-image.
5+
6+
These test suites are used for running existing tests that were originally created for ODBC on the python clients that live in universe.

cmdexec/clients/python/thrift_dbr_test/__init__.py

Whitespace-only changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import databricks.sql
2+
3+
from pythontesting.pyhive_cursor_mixin import PyHiveThriftTestCase
4+
from pythontesting.tests.common.test_spark_basictests import SparkBasicSuiteBase
5+
6+
7+
# Base classes are defined in runtime:sql/hive-thriftserver/pythontesting/
8+
# They are to be combined in the test-docker-image (//cmdexec/client/dbsql-test-image)
9+
class DBSQLBasicSuite(PyHiveThriftTestCase, SparkBasicSuiteBase):
10+
error_type = databricks.sql.Error
11+
12+
13+
if __name__ == "__main__":
14+
import unittest
15+
try:
16+
import xmlrunner
17+
testRunner = xmlrunner.XMLTestRunner(output='target/test-reports', verbosity=2)
18+
except ImportError:
19+
testRunner = None
20+
unittest.main(testRunner=testRunner, verbosity=2)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import databricks.sql
2+
3+
from pythontesting.pyhive_cursor_mixin import PyHiveThriftTestCase
4+
from pythontesting.tests.common.test_spark_sqlquerytests import SQLQueryTestSuite, retry_error
5+
6+
7+
# Base classes are defined in runtime:sql/hive-thriftserver/pythontesting/
8+
# They are to be combined in the test-docker-image (//cmdexec/client/dbsql-test-image)
9+
class DBSQLSQLQueryTestSuite(PyHiveThriftTestCase, SQLQueryTestSuite):
10+
error_type = databricks.sql.Error
11+
# 1 (\S+): exception type
12+
# 2 (.+?): exception message
13+
# 3 (:?;\n.+)?: elaborate explanation in AnalysisException (not captured)
14+
exception_re = r"Error running query: (?:\[\S+\])?\s*(\S+):\s(.+?)(?:;\n.+)?$"
15+
16+
def parse_column(self, name, datatype):
17+
return f"{name}:{datatype}"
18+
19+
def get_error_from_error_type(self, e):
20+
return str(e)
21+
22+
@retry_error(90, databricks.sql.Error)
23+
def execute_single_file(self, test, code, set_commands):
24+
return super().execute_single_file(test, code, set_commands)
25+
26+
27+
if __name__ == "__main__":
28+
import unittest
29+
try:
30+
import xmlrunner
31+
testRunner = xmlrunner.XMLTestRunner(output='target/test-reports', verbosity=2)
32+
except ImportError:
33+
testRunner = None
34+
unittest.main(testRunner=testRunner, verbosity=2)

0 commit comments

Comments
 (0)