[Python] azure-kusto-data insert duplicated and corrupted data when some pattern '2_' in it

Discussão em 'Python' iniciado por Stack, Março 14, 2025.

  1. Stack

    Stack Membro Participativo

    Using azure-kusto-data@5.0.1 when running an ingest query using both URI or Ingest URI, it ingests a column with value null as soon as the previous field contains the characters 2_ in it.

    I can run the query in the azure data explorer and it works fine, but using this method it ingests null in the “value” field.

    azure data explorer table schema:

    {
    “Name”: “kpi_table”,
    “OrderedColumns”:
    [{
    “Name”: “server_timestamp”,
    “Type”: “System.DateTime”,
    “CslType”: “datetime”
    },
    {
    “Name”: “name”,
    “Type”: “System.String”,
    “CslType”: “string”
    },
    {
    “Name”: “plant_id”,
    “Type”: “System. String”,
    “CslType”: “string”
    },
    {
    “Name”: “device_key”,
    “Type”: “System.String”,
    “CslType”: “string”
    },
    {
    “Name”: “value”,
    “Type”: “System.Double”,
    “CslType”: “real”
    }]
    }


    Data to ingest:
    2025-03-13T22:06:00Z, kpi_inverter_production, #ESSSAB2, #ESSSAB2_T010JPK01KKP03, 0.0201

    Data ingested:
    2025-03-13T22:06:00Z, kpi_inverter_production, #ESSSAB2, #ESSSAB2_T010JPK01KKP03, 0.0201
    2025-03-13T22:06:00Z, kpi_inverter_production, #ESSSAB2, #ESSSAB2_T010JPK01KKP03, null

    Performs a successful ingest and 1 second later according to ingestion_time() does another ingest with value to null.

    If in the field corresponding to device_key, you replace the character 2 by 3, it ingests correctly, can it detect the pattern 2_ as special characters internally?

    Code:

    import pandas as pd
    from azure.kusto.data import KustoClient

    def __init__(self, url, database, client_id, client_secret, tenant_id):

    kcsb = KustoConnectionStringBuilder.with_aad_application_key_authentication(
    url, client_id, client_secret, tenant_id
    )
    self.conn = KustoClient(kcsb)

    def execute_kql_query(self, query: str):
    try:
    logger.debug("Executing KQL query: %s", query)
    response = self.conn.execute(self.database, query)
    if response.get_exceptions():
    raise Exception(response.get_exceptions())
    return dataframe_from_result_table(response.primary_results[0])
    except Exception as error:
    logger.error("Error executing KQL query: %s", error)
    return pd.DataFrame()


    The query is a string with an .inline ingest, and although I know it is not recommended for production environments, the error is also reproduced with streaming ingest.

    Continue reading...

Compartilhe esta Página