KustoCode.ParseAndAnalyze does not parse RealLiteralExpressions in non-english cultures
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
Línea de trabajo
Comienza en KustoCode.ParseAndAnalyze y sigue la construcción de RealLiteralExpression y su conversión de LiteralValue. Reproduce el problema con print 123.456 y datatable(A:real)[123.456,789] bajo las culturas griega y francesa, y luego verifica que los literales numéricos conserven valores de cultura invariante sin cambiar su LiteralText.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C#
- Estrellas
- 684
- Forks
- 122
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/Kusto-Query-Language
-
Dificultad 4/5 3-5 días Aptitud para principiantes 68/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
microsoft/Kusto-Query-Language#194 · 3 comentarios ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
microsoft/Kusto-Query-Language#189 · 1 reacción ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 48/100
microsoft/Kusto-Query-Language#188 · 1 comentario ·
Todos los issues de microsoft/Kusto-Query-Language
Issues similares
-
bug priority: P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Parameterless constructor is not a must-provided by user when a struct has a field initializerAbierto:watch: Not Triaged dotnet-csharp/svc fundamentals/subsvc
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Wrong values of Kernel32.FileShare.Delete and Kernel32.FileAttributes.PosixSemanticsPosiblemente ocupada @ElectLive la tomó hoy. Abiertobug good first issue help wanted
Dificultad 1/5 Menos de una hora Aptitud para principiantes 83/100
ForNeVeR/TruePath#241 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
files-community/Files#19047 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día