1 """
2 Operations on annotated ADQL trees done by parseAnnotated.
3
4 These can be considered "bug fixes" for ADQL, where we try to
5 make the parse tree more suitable for later translation into
6 SQL.
7 """
8
9
10
11
12
13
14
15 from gavo.adql import morphhelpers
16 from gavo.adql import nodes
17
18
19
20
21
22
23
24
25
26
27
29 if node.funName!='INTERSECTS':
30 return node
31 ltype = getattr(node.args[0].fieldInfo, "type", None)
32 rtype = getattr(node.args[1].fieldInfo, "type", None)
33 if ltype=='spoint':
34 return nodes.PredicateGeometryFunction(funName="CONTAINS",
35 args=node.args)
36 elif rtype=='spoint':
37 return nodes.PredicateGeometryFunction(funName="CONTAINS",
38 args=[node.args[1], node.args[0]])
39 return node
40
41
42 _builtinMorphs = {
43 'predicateGeometryFunction': _intersectsWithPointToContains,
44 }
45
46 _morpher = morphhelpers.Morpher(_builtinMorphs)
47
48 builtinMorph = _morpher.morph
49