class utils.FlowHighSubmissionClass
json_message -Readonly property-
Return the parsed sql input in a JSON format
Sample Usage
>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> FlowHighSubmissionClass.from_sql("SELECT * FROM TAB")
>>> fh.json_message
Returns
FlowHigh JSON message
'{ "version": "1.0",
"status": "OK",
"ts": "2023-01-25T18:44:58.692Z",
"statement": [
{
"pos": "0-17",
"ds": [
{
"pos": "0-17",
"type": "root",
"subType": "inline",
"out": {
"exprs": [
{
"pos": "7-8",
"refds": "TAB",
"fullref": "TAB.*",
"eltype": "asterisk"
}
],
"derived": false,
"eltype": "out"
},
"in": {
"exprs": [
{
"pos": "14-17",
"type": "table",
"subType": "physical",
"refds": "TAB",
"fullref": "TAB",
"out": {
"derived": true,
"eltype": "out"
},
"eltype": "ds"
}
],
"eltype": "in"
},
"eltype": "ds"
}
],
"antiPatterns": [
{
"type": "AP_05",
"pos": [
"7-8"
],
"eltype": "antiPattern"
}
],
"rawInput": "SELECT * FROM TAB",
"eltype": "statement"
}
],
"eltype": "parSeQL"}'
xml_message -Readonly property-
Return the parsed sql input in XML format
Sample Usage
>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("SELECT * FROM TAB")
>>> fh.xml_message
Returns
FlowHigh XML message
'<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n<parSeQL version="1.0" status="OK" ts="2023-02-23T10:00:39.439Z">\n <statements>\n <statement pos="0-17">\n <ds pos="0-17" type="root" subType="inline">\n <out derived="false">\n <asterisk pos="7-8" refds="TAB" fullref="TAB.*"/>\n </out>\n <in>\n <ds pos="14-17" type="table" subType="physical" refds="TAB" fullref="TAB">\n <out derived="true"/>\n </ds>\n </in>\n </ds>\n <antiPatterns type="AP_05">\n <pos>7-8</pos>\n </antiPatterns>\n <rawInput>SELECT * FROM TAB</rawInput>\n </statement>\n </statements>\n</parSeQL>\n'
get_out_columns(statement: model.Statement) from builtins.type
Get the set of columns returned by the input query
Parameters
statement: The input statement object with the submitted SQL
Sample Usage
>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("SELECT * FROM TAB")
>>> [fh.get_out_columns(s) for s in fh.get_statements()]
Returns
the set of column returned by the input query
[[<flowhigh.model.Asterisk.Asterisk object at 0x7fadd0bb6970>]]
Roughly equivalent to:
>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("SELECT * FROM TAB")
>>> [fh.get_main_dataset(s).out.exprs for s in fh.get_statements()]
get_tables() from builtins.type
Returns the list of table used in the statement
Parameters
Sample Usage
>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("SELECT id FROM TAB GROUP BY 1")
>>> fh.get_tables()
Returns
the list of DBO objects representing a physical table
[<model.DBO.DBO object at 0x7fa2b5f31dc0>]
Roughly equivalent to:
>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("SELECT * FROM TAB")
>>> [dbo for dbo in fh.get_DBO_hierarchy() if dbo.type_ == "TABLE"]
get_table_columns(table: model.DBO) from builtins.type
Returns the list of attributes and expressions selected from the table
Parameters
table: The DBO representing the physical table
Sample Usage
>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("SELECT id FROM TAB GROUP BY 1")
>>> [fh.get_table_columns(tab) for tab in fh.get_tables()]
Returns
The list of Attr and Expr selected from the table
[[<model.Attr.Attr object at 0x7f1b06d84fa0>]]
get_antipattern_of_statement(statement: model.Statement) from builtins.type
Returns the Anti-patterns for a statement
Parameters
statement: The input statement object with the submitted SQL
>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("SELECT * FROM TAB GROUP BY 1")
>>> [fh.get_antipattern_of_statement(s) for s in fh.get_statements()]
Returns
the Anti-patterns found for the Statement object
[[<flowhigh.model.AntiPattern.AntiPattern object at 0x7fb2bee95130>, <flowhigh.model.AntiPattern.AntiPattern object at 0x7fb2bee952b0>]]
Roughly equivalent to:
>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("SELECT * FROM TAB GROUP BY 1")
>>> [s.antiPatterns for s in fh.get_statements()]
get_all_antipatterns() from builtins.type
Returns Anti-Patterns of all the statements
Sample Usage
>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("SELECT * FROM TAB GROUP BY 1; SELECT * FROM TAB1 GROUP BY 1")
>>> fh.get_all_antipatterns()
Returns
the list of Anti-patterns in all the statements
[<flowhigh.model.AntiPattern.AntiPattern object at 0x7fb2bee954f0>, <flowhigh.model.AntiPattern.AntiPattern object at 0x7fb2bee953a0>, <flowhigh.model.AntiPattern.AntiPattern object at 0x7fb2bee50220>, <flowhigh.model.AntiPattern.AntiPattern object at 0x7fb2bee50340>]
get_where_cols(statement: model.Statement) from builtins.type
Returns the list of attributes used in any WHERE clause
Parameters
statement: The input statement object with the submitted SQL
Sample Usage
>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("SELECT * FROM TAB WHERE ID = 1")
>>> [fh.get_where_cols(s) for s in fh.get_statements()]
Returns
the list of Attr used in filters
[<model.Attr.Attr object at 0x7fc3c2add070>]
Roughly equivalent to:
def get_where_cols(node: TreeNode, accum: List):
if not node:
return
if isinstance(node, Ds) and node.modifiers:
cols = [self.find_descendants_of_type(f.op, (Attr,)) for f in node.modifiers
if isinstance(f, Filter) and f.type_ == 'filtreg']
for child in node.get_children():
get_where_cols(child, accum)
get_having_cols(statement: model.Statement) from builtins.type
Returns the list of attributes used in a HAVING clause
Parameters
statement: The input statement object with the submitted SQL
Sample Usage
>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("SELECT id, count(id) FROM TAB GROUP BY 1 HAVING count(id) > 1")
>>> [fh.get_having_cols(s) for s in fh.get_statements()]
Returns
the list of Attr used in HAVING clauses
[<model.Attr.Attr object at 0x7fc3c2add070>]
Roughly equivalent to:
def get_having_cols(node: TreeNode, accum: List):
if not node:
return
if isinstance(node, Ds) and node.modifiers:
exprs = [f.op for f in node.modifiers if isinstance(f, Filter) and f.type_ == 'filtagg']
for e in exprs:
for attr in self.find_descendants_of_type(e, (Attr,)):
if attr.attref:
exprs.append(self.search_origin_reference(attr.attref))
continue
accum.append(self.get_object_from_dbohier(attr.dboref))
for child in node.get_children():
get_having_cols(child, accum)
get_orderby_cols(statement: model.Statement) from builtins.type
Returns the list of attributes used in ORDER BY
Parameters
statement: The input statement object with the submitted SQL
Sample Usage
>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("SELECT id FROM TAB ORDER BY 1")
>>> l = [fh.get_orderby_cols(s) for s in fh.get_statements()]
Returns
the list of Attr used in ORDER BY clauses
[<model.Attr.Attr object at 0x7fc3c2add070>]
get_groupby_cols(statement: model.Statement) from builtins.type
Returns the list of attributes used in GROUP BY
Parameters
statement: The input statement object with the submitted SQL
Sample Usage
>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("SELECT id FROM TAB GROUP BY 1")
>>> [fh.get_groupby_cols(s) for s in fh.get_statements()]
Returns
the list of Attr objects used in GROUP BY clauses
[<model.Attr.Attr object at 0x7fc3c2add070>]