Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

KustoCode.ParseAndAnalyze does not parse RealLiteralExpressions in non-english cultures

Aperta
#197 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
csharp
Ambito
compilers

Direzione di ricerca

Inizia da KustoCode.ParseAndAnalyze e segui la costruzione di RealLiteralExpression e la relativa conversione di LiteralValue. Riproduci il problema con print 123.456 e datatable(A:real)[123.456,789] nelle culture greca e francese, quindi verifica che i valori letterali numerici mantengano valori basati sulla cultura invariante senza modificare il loro LiteralText.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

The input
print 123.456
will generate a parse-tree with a LiteralExpression whose LiteralValue property contains 123456 if the culture is set to Greek. If the culture is set to french, it will generate a LiteralValue of 0

This seems incorrect; the documentation I've found implies that KQL always uses invariant-culture for number parsing. Note, this is not problem with the print operator; the same issue can be demonstrated with

datatable(A:real)[123.456,789]

The following code can be used to demonstrate the problem

using System.Globalization;
using System.Text;
using Kusto.Language;
using Kusto.Language.Symbols;
using Kusto.Language.Syntax;

var cultureName = "el-GR"; //problem found with greek culture but also demonstrated with french
CultureInfo.CurrentUICulture = CultureInfo.CurrentCulture = new CultureInfo(cultureName);

var query = "print 123.456";

var kustoCode = KustoCode.ParseAndAnalyze(query, GlobalState.Default);
DumpKustoTree(kustoCode);
return;

void DumpKustoTree(KustoCode tree)
{
    var sb = new StringBuilder();
    var indent = 0;
    SyntaxElement.WalkNodes(
        tree.Syntax,
        node =>
        {
            sb.Append(new string(' ', indent));
            sb.AppendLine(
                $"{node.Kind}: {node.ToString(IncludeTrivia.SingleLine)}: {SchemaDisplay.GetText((node as Expression)?.ResultType)}");
            if (node is LiteralExpression literal)
            {
                var value = literal.LiteralValue;
                var v = value is IFormattable f
                    ? f.ToString(null, CultureInfo.InvariantCulture)
                    : value?.ToString() ?? "<null>";
                sb.AppendLine(new string(' ', indent) + $"LITERAL {value!.GetType().Name}  {v}");
            }

            indent++;
        },
        _ => { indent--; });

    Console.WriteLine(sb.ToString());
}

This generates the following output:

QueryBlock: print 123.456:
 List: :
 List: print 123.456:
  SeparatedElement: print 123.456:
   ExpressionStatement: print 123.456:
    PrintOperator: print 123.456: (print_0: real)
     List: 123.456:
      SeparatedElement: 123.456:
       RealLiteralExpression: 123.456: real
       LITERAL Double  123456

The problem occurs as far back as version 11.0.0 of the library.

It's possible that there is some hidden setup or parameter I'm missing that would force the use of invariant culture, other than that the best workarounds would seem to be to force the current culture to Invariant while parsing or perhaps to ignore the LiteralValue in the property and parse it out manually from the LiteralText using invariantculture.

Lingua principale
C#
Stelle
684
Fork
122
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/Kusto-Query-Language

Tutte le issue di microsoft/Kusto-Query-Language

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.