KustoCode.ParseAndAnalyze does not parse RealLiteralExpressions in non-english cultures
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/Kusto-Query-Language
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
microsoft/Kusto-Query-Language#194 · 3 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
microsoft/Kusto-Query-Language#189 · 1 reazione ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
microsoft/Kusto-Query-Language#188 · 1 commento ·
Tutte le issue di microsoft/Kusto-Query-Language
Issue simili
-
Backend enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
UI: money shows the minus sign next to the number, not before the currency (IL -3.0m, not -IL 3.0m)Apertaarea: sim area: unity enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
eyalgolan/statecraft-israel#1107 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
dimitar-radenkov/Pointframe#271 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
qew21/Genshin-Subtitles#45 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
HoffmanEngineering/3d-print-log-api#274 ·
I maintainer di solito rispondono entro 1 giorno