Repository: Azure/pykusto

Issue:
Retry config causes an exception beacuse of bug in argumets order in client execute function
In `_src.client.py` the function `execute` is defined as follows:
`def execute(self, query: KQL, retry_config: RetryConfig = None) -> KustoResponse:
      return self.__database.execute(query, retry_config)`

but the `database.execute` function receives three arguments, without explicitly naming the argument as retry_config, it is used as the properties argument.

`    def execute(self, query: KQL, properties: ClientRequestProperties = None, retry_config: RetryConfig = None) -> KustoResponse:
        return self.__client.execute(self.__name, query, properties, retry_config)`

Discussion:

Patch:
diff --git a/pykusto/_src/client.py b/pykusto/_src/client.py
index 66c39f6..d18fa82 100644
--- a/pykusto/_src/client.py
+++ b/pykusto/_src/client.py
@@ -371,7 +371,7 @@ class Table(_ItemFetcher):
         return KQL(table_names[0])
 
     def execute(self, query: KQL, retry_config: RetryConfig = None) -> KustoResponse:
-        return self.__database.execute(query, retry_config)
+        return self.__database.execute(query, retry_config=retry_config)
 
     def get_columns_names(self) -> Generator[str, None, None]:
         yield from self._get_item_names()


Test patch:
diff --git a/test/test_client.py b/test/test_client.py
index 5fc05c2..930e81e 100644
--- a/test/test_client.py
+++ b/test/test_client.py
@@ -222,3 +222,28 @@ class TestClient(TestBase):
             KustoError("Mock exception for test", None),
             lambda: Query(table).take(5).execute(),
         )
+
+    def test_override_retry_config_for_query(self):
+        num_retries = 2
+        num_failed_attempts = num_retries - 1
+        retry_sleep_time = 0.1
+
+        mock_kusto_client = self.unreliable_mock_kusto_client(num_failed_attempts)
+        table = PyKustoClient(mock_kusto_client, fetch_by_default=False)['test_db']['mock_table']
+        retry_config = RetryConfig(num_retries, sleep_time=retry_sleep_time, jitter=0)
+
+        with self.assertLogs(_logger, logging.INFO) as cm:
+            Query(table).take(5).execute(retry_config=retry_config)
+
+        self.assertEqual(
+            [RecordedQuery('test_db', 'mock_table | take 5')] * num_retries,
+            mock_kusto_client.recorded_queries
+        )
+        self.assertEqual(
+            [
+                f"INFO:pykusto:Attempt number {num_failed_attempts} out of {num_retries} failed, "
+                f"previous sleep time was {retry_sleep_time} seconds. "
+                f"Exception: KustoServiceError('Mock exception for test')"
+            ],
+            cm.output
+        )