Why does the TableSymbol from the ResultType always lack the Name property?
FaresKi opened this issue · 1 comments
Hi!
I'm struggling with an issue here.
I have a query composed of statements, and various expressions, including PipeExpression
s.
let variable = TableName
| where TimeGenerated > ago(check_period)
| where ColumnA == "Value"
| where ColumnB in ("A", "B")
| where ColumnC == "Value_bis";
...
I want to extract the table from this query (TableName here) and store it in my list:
public static List<string> GetTables(KustoCode code)
{
var tables = new List<string>();
GatherTables(code.Syntax);
return tables;
void GatherTables(SyntaxNode root)
{
SyntaxElement.WalkNodes(root,
fnBefore: n =>
{
if (n.ReferencedSymbol is TableSymbol t
// && code.Globals.IsDatabaseTable(t)
)
{
tables.Add(t.Name);
}
else if (n is Expression e
&& e.ResultType is TableSymbol ts
//&& code.Globals.IsDatabaseTable(ts)
)
{
tables.Add(ts.Name);
}
else if (n.GetCalledFunctionBody() is SyntaxNode body)
{
GatherTables(body);
}
},
fnDescend: n =>
// skip descending into function declarations since their bodies will be examined by the code above
!(n is FunctionDeclaration)
);
}
}
As you can see I've inspired myself from the readme but changed the return type.
What I've noticed while debugging is that despite the Parser recognizing it's a TableSymbol
, it will provide an empty ("") value for the Name
or AlternateName
.
Am I missing something?
Same issue if I provide a schema thru the Globals
.
TIA
The parser uses the TableSymbol to both represent the named tables in a database and the result of each tabular operation. All tabular operators return a different TableSymbol than they started with, never with a name, since they represent intermediate states.