@@ -27,9 +27,9 @@ def _evaluate(x, values: dict):
2727 else :
2828 raise Exception (f"Unknown binary op { x .op .text } " )
2929 elif type (x ) == SubstraitTypeParser .LiteralNumberContext :
30- return int (x .number .text )
31- elif type (x ) == SubstraitTypeParser .TypeParamContext :
32- return values [x .identifier .text ]
30+ return int (x .Number (). symbol .text )
31+ elif type (x ) == SubstraitTypeParser .ParameterNameContext :
32+ return values [x .Identifier (). symbol .text ]
3333 elif type (x ) == SubstraitTypeParser .NumericParameterNameContext :
3434 return values [x .Identifier ().symbol .text ]
3535 elif type (x ) == SubstraitTypeParser .ParenExpressionContext :
@@ -43,9 +43,10 @@ def _evaluate(x, values: dict):
4343 return max (* exprs )
4444 else :
4545 raise Exception (f"Unknown function { func } " )
46- elif type (x ) == SubstraitTypeParser .TypeContext :
46+ elif type (x ) == SubstraitTypeParser .TypeDefContext :
4747 scalar_type = x .scalarType ()
4848 parametrized_type = x .parameterizedType ()
49+ any_type = x .anyType ()
4950 if scalar_type :
5051 nullability = (
5152 Type .NULLABILITY_NULLABLE if x .isnull else Type .NULLABILITY_REQUIRED
@@ -81,8 +82,14 @@ def _evaluate(x, values: dict):
8182 )
8283 )
8384 raise Exception (f"Unknown parametrized type { type (parametrized_type )} " )
85+ elif any_type :
86+ any_var = any_type .AnyVar ()
87+ if any_var :
88+ return values [any_var .symbol .text ]
89+ else :
90+ raise Exception ()
8491 else :
85- raise Exception ("either scalar_type or parametrized_type is required" )
92+ raise Exception (f "either scalar_type, parametrized_type or any_type is required" )
8693 elif type (x ) == SubstraitTypeParser .NumericExpressionContext :
8794 return _evaluate (x .expr (), values )
8895 elif type (x ) == SubstraitTypeParser .TernaryContext :
@@ -101,7 +108,7 @@ def _evaluate(x, values: dict):
101108
102109 return _evaluate (x .finalType , values )
103110 elif type (x ) == SubstraitTypeParser .TypeLiteralContext :
104- return _evaluate (x .type_ (), values )
111+ return _evaluate (x .typeDef (), values )
105112 elif type (x ) == SubstraitTypeParser .NumericLiteralContext :
106113 return int (str (x .Number ()))
107114 else :
0 commit comments