|
46 | 46 | from databricks.sql.experimental.oauth_persistence import OAuthPersistence
|
47 | 47 |
|
48 | 48 | from databricks.sql.thrift_api.TCLIService.ttypes import (
|
49 |
| - TSparkParameter, |
| 49 | + TSparkParameter, TOperationState, |
50 | 50 | )
|
51 | 51 |
|
52 | 52 |
|
@@ -764,6 +764,11 @@ def execute(
|
764 | 764 | Both will result in the query equivalent to "SELECT * FROM table WHERE field = 'foo'
|
765 | 765 | being sent to the server
|
766 | 766 |
|
| 767 | + async_op: |
| 768 | + Denotes whether the execute command will execute the request asynchronously or not |
| 769 | + By default it is set to False, if set True the execution request will be submitted and the code |
| 770 | + will be non-blocking. User can later poll and request the result when ready |
| 771 | +
|
767 | 772 | :returns self
|
768 | 773 | """
|
769 | 774 |
|
@@ -819,14 +824,35 @@ def execute_async(
|
819 | 824 | self,
|
820 | 825 | operation: str,
|
821 | 826 | parameters: Optional[TParameterCollection] = None,
|
822 |
| - ): |
823 |
| - return self.execute(operation, parameters, True) |
| 827 | + ) -> "Cursor": |
| 828 | + """ |
| 829 | +
|
| 830 | + Execute a query and do not wait for it to complete and just move ahead |
| 831 | +
|
| 832 | + Internally it calls execute function with async_op=True |
| 833 | + :param operation: |
| 834 | + :param parameters: |
| 835 | + :return: |
| 836 | + """ |
| 837 | + self.execute(operation, parameters, True) |
| 838 | + return self |
824 | 839 |
|
825 |
| - def get_query_state(self): |
| 840 | + def get_query_state(self) -> "TOperationState": |
| 841 | + """ |
| 842 | + Get the state of the async executing query or basically poll the status of the query |
| 843 | +
|
| 844 | + :return: |
| 845 | + """ |
826 | 846 | self._check_not_closed()
|
827 | 847 | return self.thrift_backend.get_query_state(self.active_op_handle)
|
828 | 848 |
|
829 | 849 | def get_execution_result(self):
|
| 850 | + """ |
| 851 | +
|
| 852 | + Checks for the status of the async executing query and fetches the result if the query is finished |
| 853 | + If executed sets the active_result_set to the obtained result |
| 854 | + :return: |
| 855 | + """ |
830 | 856 | self._check_not_closed()
|
831 | 857 |
|
832 | 858 | operation_state = self.get_query_state()
|
|
0 commit comments