OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TableFunctionsFactory_transformers.DefaultValueAnnotationTransformer Class Reference
+ Inheritance diagram for TableFunctionsFactory_transformers.DefaultValueAnnotationTransformer:
+ Collaboration diagram for TableFunctionsFactory_transformers.DefaultValueAnnotationTransformer:

Public Member Functions

def visit_udtf_node
 
- Public Member Functions inherited from TableFunctionsFactory_transformers.AstTransformer
def visit_udtf_node
 
def visit_composed_node
 
def visit_arg_node
 
def visit_primitive_node
 
def visit_template_node
 
def visit_annotation_node
 
- Public Member Functions inherited from TableFunctionsFactory_transformers.AstVisitor
def visit_udtf_node
 
def visit_composed_node
 
def visit_arg_node
 
def visit_primitive_node
 
def visit_annotation_node
 
def visit_template_node
 

Detailed Description

Definition at line 306 of file TableFunctionsFactory_transformers.py.

Member Function Documentation

def TableFunctionsFactory_transformers.DefaultValueAnnotationTransformer.visit_udtf_node (   self,
  udtf_node 
)
* Typechecks default value annotations.

Definition at line 307 of file TableFunctionsFactory_transformers.py.

References run_benchmark_import.type.

308  def visit_udtf_node(self, udtf_node):
309  """
310  * Typechecks default value annotations.
311  """
312  udtf_node = super(type(self), self).visit_udtf_node(udtf_node)
313 
314  for t in udtf_node.inputs:
315  for a in filter(lambda x: x.key == "default", t.annotations):
316  if not t.type.is_scalar():
317  raise TransformerException(
318  'Error in function "%s", input annotation \'%s=%s\'. '
319  '\"default\" annotation is only supported for scalar types!'\
320  % (udtf_node.name, a.key, a.value)
321  )
322  literal = literal_eval(a.value)
323  lst = [(bool, 'is_boolean_scalar'), (int, 'is_integer_scalar'), (float, 'is_float_scalar'),
324  (str, 'is_string_scalar')]
325 
326  for (cls, mthd) in lst:
327  if type(literal) is cls:
328  assert isinstance(t, tf_node.ArgNode)
329  m = getattr(t.type, mthd)
330  if not m():
331  raise TransformerException(
332  'Error in function "%s", input annotation \'%s=%s\'. '
333  'Argument is of type "%s" but value type was inferred as "%s".'
334  % (udtf_node.name, a.key, a.value, t.type.type, type(literal).__name__))
335  break
336 
337  return udtf_node
338 

The documentation for this class was generated from the following file: