Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
cbee189
Import changes from other branch
AsafMah Dec 24, 2025
efa4507
Added tests
AsafMah Dec 24, 2025
f1404be
Is this test really fails it?
AsafMah Dec 24, 2025
c8dbf51
Fixed test
AsafMah Dec 24, 2025
e79a447
Fixed test
AsafMah Dec 24, 2025
da9e428
skip
AsafMah Dec 24, 2025
d4e5aa5
Remove
AsafMah Dec 24, 2025
acd5627
back
AsafMah Dec 24, 2025
5bc74d8
test
AsafMah Dec 24, 2025
62ae19f
test
AsafMah Dec 24, 2025
db565d8
test
AsafMah Dec 24, 2025
99f1030
fixed warning
AsafMah Dec 24, 2025
6159d6e
fixed warning
AsafMah Dec 24, 2025
b1c293a
rename
AsafMah Dec 24, 2025
8956991
rename
AsafMah Dec 24, 2025
cbb068a
Increate timeout
AsafMah Dec 24, 2025
50e65e5
Increate timeout
AsafMah Dec 24, 2025
6c37e9e
Same group
AsafMah Dec 24, 2025
30f62e6
Separate table per test
AsafMah Dec 24, 2025
fce6741
Close clients
AsafMah Dec 24, 2025
a5855c9
Close clients
AsafMah Dec 24, 2025
bb7669b
Close clients
AsafMah Dec 24, 2025
a0442f9
Removed shared state
AsafMah Dec 24, 2025
c20b350
Separate managed streaming
AsafMah Dec 24, 2025
59dcc2e
Fixed test
AsafMah Dec 24, 2025
2f7d7b2
w
AsafMah Dec 24, 2025
d209602
w
AsafMah Dec 24, 2025
9074774
w
AsafMah Dec 24, 2025
9a30072
Update azure-kusto-data/azure/kusto/data/helpers.py
AsafMah Dec 25, 2025
ca0b31f
Update azure-kusto-ingest/tests/test_e2e_ingest.py
AsafMah Dec 25, 2025
8dfd9d0
Fix
AsafMah Dec 25, 2025
e759d3b
Fix
AsafMah Dec 25, 2025
d8f9b47
Add retry
AsafMah Dec 25, 2025
5e9f133
Update azure-kusto-ingest/tests/test_e2e_ingest.py
AsafMah Dec 25, 2025
31b43f4
Update azure-kusto-ingest/tests/test_e2e_ingest.py
AsafMah Dec 25, 2025
b86647d
Add sleep
AsafMah Dec 25, 2025
ac65639
Try a different way
AsafMah Dec 25, 2025
b764def
Merge branch 'master' into pandas-try-again
AsafMah Dec 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [6.0.1] - 2025-12-25

### Fixed
- Changed extra's name back to `aio`
- Fixed handling of datetime columns in old pandas versions.
- Fixed encoding error in `ingest_from_dataframe` when using csv data format.

## [6.0.0] - 2025-11-26
Expand Down
19 changes: 10 additions & 9 deletions azure-kusto-data/azure/kusto/data/helpers.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import json
from functools import lru_cache
from pathlib import Path
from typing import TYPE_CHECKING, Union, Callable, Dict, Optional
from typing import TYPE_CHECKING, Any, Union, Callable, Optional

if TYPE_CHECKING:
import pandas as pd
from azure.kusto.data._models import KustoResultTable, KustoStreamingResultTable

# Alias for dataframe_from_result_table converter type
Converter = Dict[str, Union[str, Callable[[str, "pd.DataFrame"], "pd.Series"]]]
Converter = dict[str, Union[str, Callable[[str, "pd.DataFrame"], "pd.Series"]]]


def load_bundled_json(file_name: str) -> Dict:
def load_bundled_json(file_name: str) -> dict[Any, Any]:
filename = Path(__file__).absolute().parent.joinpath(file_name)
with filename.open("r", encoding="utf-8") as data:
return json.load(data)
Expand Down Expand Up @@ -113,23 +113,24 @@ def parse_float(frame, col):
import numpy as np
import pandas as pd

frame[col] = frame[col].replace("NaN", np.nan).replace("Infinity", np.inf).replace("-Infinity", -np.inf)
frame[col] = frame[col].infer_objects(copy=False).replace({"NaN": np.nan, "Infinity": np.inf, "-Infinity": -np.inf})
frame[col] = pd.to_numeric(frame[col], errors="coerce").astype(pd.Float64Dtype()) # pyright: ignore[reportCallIssue,reportArgumentType]

return frame[col]


def parse_datetime(frame, col):
def parse_datetime(frame, col, force_version: Optional[str] = None) -> "pd.Series":
# Pandas before version 2 doesn't support the "format" arg
import pandas as pd

args = {}
if pd.__version__.startswith("2."):
if (force_version or pd.__version__).startswith("2."):
args = {"format": "ISO8601", "utc": True}
else:
# if frame contains ".", replace "Z" with ".000Z"
# == False is not a mistake - that's the pandas way to do it
contains_dot = frame[col].str.contains(".")
frame.loc[not contains_dot, col] = frame.loc[not contains_dot, col].str.replace("Z", ".000Z")
# Using bitwise NOT (~) on the boolean Series is the idiomatic pandas way to negate the mask
contains_dot = frame[col].str.contains("\\.")
frame.loc[~contains_dot, col] = frame.loc[~contains_dot, col].str.replace("Z", ".000Z")
frame[col] = pd.to_datetime(frame[col], errors="coerce", **args)
return frame[col]

Expand Down
30 changes: 29 additions & 1 deletion azure-kusto-data/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pytest

from azure.kusto.data._models import KustoResultTable
from azure.kusto.data.helpers import dataframe_from_result_table
from azure.kusto.data.helpers import dataframe_from_result_table, parse_datetime

Check warning on line 10 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Type of "parse_datetime" is partially unknown   Type of "parse_datetime" is "(frame: Unknown, col: Unknown, force_version: str | None = None) -> Series" (reportUnknownVariableType)

Check warning on line 10 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Type of "parse_datetime" is partially unknown   Type of "parse_datetime" is "(frame: Unknown, col: Unknown, force_version: str | None = None) -> Series" (reportUnknownVariableType)

Check warning on line 10 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.9)

Type of "parse_datetime" is partially unknown   Type of "parse_datetime" is "(frame: Unknown, col: Unknown, force_version: str | None = None) -> Series" (reportUnknownVariableType)

Check warning on line 10 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Type of "parse_datetime" is partially unknown   Type of "parse_datetime" is "(frame: Unknown, col: Unknown, force_version: str | None = None) -> Series" (reportUnknownVariableType)

Check warning on line 10 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.13)

Type of "parse_datetime" is partially unknown   Type of "parse_datetime" is "(frame: Unknown, col: Unknown, force_version: str | None = None) -> Series" (reportUnknownVariableType)
from azure.kusto.data.response import KustoResponseDataSetV2
import pandas
import numpy
Expand Down Expand Up @@ -128,3 +128,31 @@

assert df["Date"][0] == pandas.Timestamp(year=2023, month=12, day=12, hour=1, minute=59, second=59, microsecond=352000, tzinfo=datetime.timezone.utc)
assert df["Date"][1] == pandas.Timestamp(year=2023, month=12, day=12, hour=1, minute=54, second=44, tzinfo=datetime.timezone.utc)


def test_datetime_parsing():
"""Test parse_datetime function with different pandas versions and datetime formats"""

# Test with pandas v2 behavior (force version 2)
df_v2 = pandas.DataFrame(
{
"mixed": ["2023-12-12T01:59:59.352Z", "2023-12-12T01:54:44Z"],
}
)

# Force pandas v2 behavior
result_v2 = parse_datetime(df_v2, "mixed", force_version="2.0.0")
assert str(result_v2[0]) == "2023-12-12 01:59:59.352000+00:00"

Check warning on line 145 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Unknown, dtype[Any]] | Unknown" (reportUnknownArgumentType)

Check warning on line 145 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Unknown, Unknown] | Unknown" (reportUnknownArgumentType)

Check warning on line 145 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.9)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Any, Unknown] | Unknown | ndarray[Any, dtype[Unknown]]" (reportUnknownArgumentType)

Check warning on line 145 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Unknown, dtype[Any]] | Unknown" (reportUnknownArgumentType)

Check warning on line 145 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.13)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Unknown, dtype[Any]] | Unknown" (reportUnknownArgumentType)
assert str(result_v2[1]) == "2023-12-12 01:54:44+00:00"

Check warning on line 146 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Unknown, dtype[Any]] | Unknown" (reportUnknownArgumentType)

Check warning on line 146 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Unknown, Unknown] | Unknown" (reportUnknownArgumentType)

Check warning on line 146 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.9)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Any, Unknown] | Unknown | ndarray[Any, dtype[Unknown]]" (reportUnknownArgumentType)

Check warning on line 146 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Unknown, dtype[Any]] | Unknown" (reportUnknownArgumentType)

Check warning on line 146 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.13)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Unknown, dtype[Any]] | Unknown" (reportUnknownArgumentType)
# Test with pandas v1 behavior (force version 1)

df_v1 = pandas.DataFrame(
{
"mixed": ["2023-12-12T01:59:59.352Z", "2023-12-12T01:54:44Z"],
}
)

# Force pandas v1 behavior - it should add .000 to dates without milliseconds
result_v1 = parse_datetime(df_v1, "mixed", force_version="1.5.3")
assert str(result_v1[0]) == "2023-12-12 01:59:59.352000+00:00"

Check warning on line 157 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Unknown, dtype[Any]] | Unknown" (reportUnknownArgumentType)

Check warning on line 157 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Unknown, Unknown] | Unknown" (reportUnknownArgumentType)

Check warning on line 157 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.9)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Any, Unknown] | Unknown | ndarray[Any, dtype[Unknown]]" (reportUnknownArgumentType)

Check warning on line 157 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Unknown, dtype[Any]] | Unknown" (reportUnknownArgumentType)

Check warning on line 157 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.13)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Unknown, dtype[Any]] | Unknown" (reportUnknownArgumentType)
assert str(result_v1[1]) == "2023-12-12 01:54:44+00:00"

Check warning on line 158 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Unknown, dtype[Any]] | Unknown" (reportUnknownArgumentType)

Check warning on line 158 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Unknown, Unknown] | Unknown" (reportUnknownArgumentType)

Check warning on line 158 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.9)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Any, Unknown] | Unknown | ndarray[Any, dtype[Unknown]]" (reportUnknownArgumentType)

Check warning on line 158 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Unknown, dtype[Any]] | Unknown" (reportUnknownArgumentType)

Check warning on line 158 in azure-kusto-data/tests/test_helpers.py

View workflow job for this annotation

GitHub Actions / build (3.13)

Argument type is partially unknown   Argument corresponds to parameter "object" in function "__new__"   Argument type is "Series | Any | ndarray[Unknown, dtype[Any]] | Unknown" (reportUnknownArgumentType)
Loading
Loading