@@ -250,19 +250,55 @@ def _wait_until_command_done(self, command_id, initial_status):
250250 def execute (self , operation , query_params = None , metadata = None ):
251251 self ._check_not_closed ()
252252 self ._close_and_clear_active_result_set ()
253+ return self ._create_result_set_from_command (
254+ sql_command = messages_pb2 .SqlCommand (command = [operation ]))
253255
254- # Execute the command
256+ def tables (self , catalog_name = None , schema_name = None , table_name = None , table_types = []):
257+ self ._check_not_closed ()
258+ self ._close_and_clear_active_result_set ()
259+
260+ get_tables_command = messages_pb2 .GetTablesCommand (
261+ catalog_name = catalog_name ,
262+ schema_name = schema_name ,
263+ table_name = table_name ,
264+ table_types = table_types )
265+
266+ return self ._create_result_set_from_command (get_tables_command = get_tables_command )
267+
268+ def columns (self , catalog_name = None , schema_name = None , table_name = None , column_name = None ):
269+ self ._check_not_closed ()
270+ self ._close_and_clear_active_result_set ()
271+
272+ get_columns_command = messages_pb2 .GetColumnsCommand (
273+ catalog_name = catalog_name ,
274+ schema_name = schema_name ,
275+ table_name = table_name ,
276+ column_name = column_name )
277+
278+ return self ._create_result_set_from_command (get_columns_command = get_columns_command )
279+
280+ def schemas (self , catalog_name = None , schema_name = None ):
281+ self ._check_not_closed ()
282+ self ._close_and_clear_active_result_set ()
283+
284+ get_schemas_command = messages_pb2 .GetSchemasCommand (
285+ catalog_name = catalog_name , schema_name = schema_name )
286+
287+ return self ._create_result_set_from_command (get_schemas_command = get_schemas_command )
288+
289+ def _create_result_set_from_command (self , ** command_arg ):
290+ # Create execute command request
255291 execute_command_request = messages_pb2 .ExecuteCommandRequest (
256292 session_id = self .connection .session_id ,
257293 client_command_id = None ,
258- sql_command = messages_pb2 .SqlCommand (command = [operation ]),
259294 conf_overlay = None ,
260295 row_limit = None ,
261296 result_options = messages_pb2 .CommandResultOptions (
262297 max_rows = self .arraysize ,
263298 max_bytes = self .buffer_size_bytes ,
264299 include_metadata = True ,
265- ))
300+ ),
301+ ** command_arg )
266302
267303 execute_command_response = self .connection .base_client .make_request (
268304 self .connection .base_client .stub .ExecuteCommand , execute_command_request )
0 commit comments