Closed oi-raanne closed 1 month ago
Test code: ` my_odata_query2 = "endswith(CompanyName,'Futterkiste')".strip()
lexer = ODataLexer()
parser = ODataParser()
ast = parser.parse(lexer.tokenize(my_odata_query2))
bqVisitor = AstToSqlVisitor()
print("***")
print(f"SQL query: {bqVisitor.visit(ast)}") `
Output
Failed to infer type for Identifier(name='CompanyName', namespace=()) SQL query: "CompanyName" LIKE '%Futterkiste'
Fair point. I've turned it into a debug
log for now, so it's easier to turn off but users can at least know the cause of type-related failures.
The reason we need type inference is to know which functions we'd need to call, e.g. endswith(x, y)
is valid for both string
and list
types and we need to pick the correct implementation based on the types of the arguments.
odata-query
cannot infer this type for every Node
. The main failure case is for Identifier
nodes, for which we'd have to know the entire schema of the database up front.
Base AST visitor for SQL throws warning 'Failed to infer type for Identifier(name='CompanyName', namespace=())' for
endswith(CompanyName,'Futterkiste')
. This is harmless warning, but needs to be fixed as this is a valid expression as per OData spec