@@ -119,23 +119,8 @@ class TestParameterizedQueries(PySQLPytestTestCase):
119119 def _get_inline_table_column (self , value ):
120120 return self .inline_type_map [Primitive (value )]
121121
122- @pytest .fixture (scope = "class" )
123- def inline_table (self , connection_details ):
124- self .arguments = connection_details .copy ()
125- """This table is necessary to verify that a parameter sent with INLINE
126- approach can actually write to its analogous data type.
127-
128- For example, a Python Decimal(), when rendered inline, should be able
129- to read/write into a DECIMAL column in Databricks
130-
131- Note that this fixture doesn't clean itself up. So the table will remain
132- in the schema for use by subsequent test runs.
133- """
134-
135- # Generate unique table name to avoid conflicts in parallel execution
136- table_name = f"pysql_e2e_inline_param_test_table_{ str (uuid4 ()).replace ('-' , '_' )} "
137- self .inline_table_name = table_name
138-
122+ def _create_inline_table (self , table_name ):
123+ """Create the inline test table with all necessary columns"""
139124 query = f"""
140125 CREATE TABLE IF NOT EXISTS { table_name } (
141126 null_col INT,
@@ -160,6 +145,24 @@ def inline_table(self, connection_details):
160145 with conn .cursor () as cursor :
161146 cursor .execute (query )
162147
148+ @pytest .fixture (scope = "class" )
149+ def inline_table (self , connection_details ):
150+ self .arguments = connection_details .copy ()
151+ """This table is necessary to verify that a parameter sent with INLINE
152+ approach can actually write to its analogous data type.
153+
154+ For example, a Python Decimal(), when rendered inline, should be able
155+ to read/write into a DECIMAL column in Databricks
156+
157+ Note that this fixture doesn't clean itself up. So the table will remain
158+ in the schema for use by subsequent test runs.
159+ """
160+
161+ # Generate unique table name to avoid conflicts in parallel execution
162+ table_name = f"pysql_e2e_inline_param_test_table_{ str (uuid4 ()).replace ('-' , '_' )} "
163+ self .inline_table_name = table_name
164+ self ._create_inline_table (table_name )
165+
163166 @contextmanager
164167 def patch_server_supports_native_params (self , supports_native_params : bool = True ):
165168 """Applies a patch so we can test the connector's behaviour under different SPARK_CLI_SERVICE_PROTOCOL_VERSION conditions."""
@@ -184,6 +187,11 @@ def _inline_roundtrip(self, params: dict, paramstyle: ParamStyle, target_column)
184187 :paramstyle:
185188 This is a no-op but is included to make the test-code easier to read.
186189 """
190+ if not hasattr (self , 'inline_table_name' ):
191+ table_name = f"pysql_e2e_inline_param_test_table_{ str (uuid4 ()).replace ('-' , '_' )} "
192+ self .inline_table_name = table_name
193+ self ._create_inline_table (table_name )
194+
187195 table_name = self .inline_table_name
188196 INSERT_QUERY = f"INSERT INTO { table_name } (`{ target_column } `) VALUES (%(p)s)"
189197 SELECT_QUERY = f"SELECT { target_column } `col` FROM { table_name } LIMIT 1"
0 commit comments