class utils.FlowHighSubmissionClass

from_file(name: str) from builtins.type

Initialise the SDK from an SQL script

Parameters

name: filepath of the .sql script to be parsed

Sample Usage

>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> FlowHighSubmissionClass.from_file("/home/user/sample.sql")

Returns

the FlowHighSubmissionClass instance with the parsed SQL input

<flowhigh.utils.converter.FlowHighSubmissionClass object at 0x7f0b1c87d790>

from_sql(sql: str) from builtins.type

Initialise the SDK from an SQL query

Parameters

sql: the query text to parse

Sample Usage

>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> FlowHighSubmissionClass.from_sql("SELECT * FROM TAB")

Returns

the FlowHighSubmissionClass instance with the parsed SQL input

<flowhigh.utils.converter.FlowHighSubmissionClass object at 0x7f0b1c87dc70>

get_statements() from builtins.type

Collect the Statement object(s) that map any DDL, DQL, or DML commands submitted

Sample Usage

>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("SELECT * FROM TAB")
>>> fh.get_statements()

Returns

the list of statements that the query is made up of

[<flowhigh.model.Statement.Statement object at 0x7f0b1d679c40>]

get_raw_query(statement: model.Statement) from builtins.type

Get the raw query text

Parameters

statement: the single statement text to extract

Sample Usage

>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("SELECT * FROM TAB")
>>> [fh.get_raw_query(s) for s in fh.get_statements()]

Returns

the SQL input text

['SELECT * FROM TAB']

get_node_raw_text(node: model.TreeNode) from builtins.type

Get the sql text at the node’s coordinates in query (i.e. position in text)

Parameters

node: the TreeNode object to extract from the tree

Sample Usage

>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("SELECT * FROM TAB")
>>> [fh.get_node_raw_text(s) for s in fh.get_statements()]

Returns

the sql substring at the node’s coordinates

['SELECT * FROM TAB']

find_descendants_of_type(node: model.TreeNode, clazz: Union[Tuple, model.TreeNode], all: bool = True) from builtins.type

Find the list of children TreeNode in the hierarchy based on their type

Parameters

node: the tree object node
clazz: the type(s) to search. This can be a single type or a Tuple
all: if False, don't continue searching in sub-levels after a matching node is found. Default: True

Sample Usage

>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> from flowhigh.model import Ds
>>> fh = FlowHighSubmissionClass.from_sql("SELECT * FROM TAB")
>>> [fh.find_descendants_of_type(s, (Ds,)) for s in fh.get_statements()]

Returns

the list of descendants or None if no children elements found

[<flowhigh.model.Ds.Ds object at 0x7fadd0bb62b0>]

find_ancestor_of_type(node: model.TreeNode, clazz: Union[Tuple, model.TreeNode]) from builtins.type

Find the node’s immediate ancestor in tree by its type

Parameters

node: the tree object node
clazz: the type(s) to search. This can be a single type or a Tuple

Sample Usage

>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> from flowhigh.model import ParSeQL
>>> fh = FlowHighSubmissionClass.from_sql("SELECT * FROM TAB")
>>> [fh.find_ancestor_of_type(s, (ParSeQL,)) for s in fh.get_statements()]

Returns

the WeakProxy node’s ancestor or None if no ancestors are found

[<weakproxy at 0x7f00822ae090 to ParSeQL at 0x7f00832cb3d0>]

get_main_dataset(statement: model.Statement) from builtins.type

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_main_dataset(s) for s in fh.get_statements()]

Returns

the statement’s main dataset which represents the entry point to traverse the parsed tree

[<flowhigh.model.Ds.Ds object at 0x7f95e8c431c0>]

get_nodes_by_types(types: Union[Tuple, str]) from builtins.type

Get the list of nodes in the tree for a given type

Parameters

types: the type(s) to search. This can be a single type or a Tuple

Sample Usage

>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> from flowhigh.model import Ds
>>> fh = FlowHighSubmissionClass.from_sql("SELECT * FROM TAB")
>>> fh.get_nodes_by_types((Ds,))

Returns

the list of all nodes matching the given type(s)

[<flowhigh.model.Ds.Ds object at 0x7fadd0bb6850>, <flowhigh.model.Ds.Ds object at 0x7fadd0bb62b0>]

search_node_by_id(node_id: int) from builtins.type

Find a TreeNode in the tree based on its internal id

Parameters

node_id: internal id of a TreeNode

Sample Usage

>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("SELECT * FROM TAB UNION SELECT * FROM TAB1")
>>> fh.search_node_by_id(5)

Returns

a TreeNode instance with the given id or None

<flowhigh.model.Ds.Ds object at 0x7fadd0bb62b0>

search_node_by_pos(pos: str) from builtins.type

Find a node based on its position in query

Parameters

pos: Start position and the length of the object in the query

Sample Usage

>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("SELECT * FROM TAB")
>>> fh.search_node_by_pos("12-3")

Returns

the node at the given coordinates or None

<flowhigh.model.Ds.Ds object at 0x7fadd0bb62b0>

search_origin_reference(attref: str) from builtins.type

Find a node based on its expression origin reference

Parameters

attref: the coordinates of the referenced parent expression

Sample Usage

>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("select id from (SELECT COALESCE(NAME, SURNAME) ID FROM TAB)T")
>>> fh.search_origin_reference("23-26")

Returns

the node at the given coordinates or None

<model.Func.Func object at 0x7f7edb45f520>

get_DBO_hierarchy() from builtins.type

Get the DBO hierarchy and all its DBO objects (databases, schemas and tables)

Sample Usage

>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("SELECT * FROM TAB")
>>> fh.get_DBO_hierarchy()

Returns The hierarchy with all its DBOs

get_object_from_dbohier(dboref: str) from builtins.type

Look up the DBO element in the hierarchy based on the oid

Parameters

dboref: the reference of the DBO to search

Sample Usage

>>> from flowhigh.utils.converter import FlowHighSubmissionClass
>>> fh = FlowHighSubmissionClass.from_sql("select id from (SELECT COALESCE(NAME, SURNAME) ID FROM TAB)T")
>>> fh.get_object_from_dbohier("C1")

Returns

The DBO matching the given dboref (if any)

<model.DBO.DBO object at 0x7f8439ddf2e0>