How to use the expression.SgExpression.ExtractTokensFromExpressions function in Expression

To help you get started, we’ve selected a few Expression examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lnishan / SQLGitHub / components / session.py View on Github external
self._source = source
        self._condition = condition
        self._groups = groups
        self._having = having
        self._orders = orders
        self._limit = limit

        rel_keys = SgExpression.ExtractTokensFromExpressions(self._field_exprs)
        if self._condition:
            rel_keys += SgExpression.ExtractTokensFromExpressions([self._condition])
        if self._groups:
            rel_keys += SgExpression.ExtractTokensFromExpressions(self._groups)
        if self._having:
            rel_keys += SgExpression.ExtractTokensFromExpressions([self._having])
        if self._orders:
            rel_keys += SgExpression.ExtractTokensFromExpressions(self._orders[0])
        rel_keys = list(set(rel_keys))
        self._fetcher = table_fetcher.SgTableFetcher(github, rel_keys)
github lnishan / SQLGitHub / components / session.py View on Github external
if meets[i]:
                    filtered_table.Append(row)
        else:
            filtered_table = source_table
        if not filtered_table[:]:
            return self._GetEmptyTable()
        
        # evaluate all necessary expressions
        # in reversed order because we process from the rightmost item first
        select_tokens = SgExpression.ExtractTokensFromExpressions(self._field_exprs[:]) 
        eval_exprs = select_tokens
        if self._orders:
            order_tokens = SgExpression.ExtractTokensFromExpressions(self._orders[0])
            eval_exprs += order_tokens
        if self._having:
            having_tokens = SgExpression.ExtractTokensFromExpressions([self._having])
            eval_exprs += having_tokens
        if self._groups:
            eval_exprs += self._groups
        res_table = SgExpression.EvaluateExpressions(filtered_table, eval_exprs)

        # group by
        if self._groups:
            res_tables = SgGrouping.GenerateGroups(res_table, self._groups)
        else:
            res_tables = [res_table]

        # having
        if self._having:
            filtered_tables = []
            for table in res_tables:
                if all(SgExpression.EvaluateExpression(table, self._having)):
github lnishan / SQLGitHub / components / session.py View on Github external
# evaluate where
        if self._condition:
            filtered_table = tb.SgTable()
            filtered_table.SetFields(source_table.GetFields())
            meets = SgExpression.EvaluateExpression(source_table, self._condition)
            for i, row in enumerate(source_table):
                if meets[i]:
                    filtered_table.Append(row)
        else:
            filtered_table = source_table
        if not filtered_table[:]:
            return self._GetEmptyTable()
        
        # evaluate all necessary expressions
        # in reversed order because we process from the rightmost item first
        select_tokens = SgExpression.ExtractTokensFromExpressions(self._field_exprs[:]) 
        eval_exprs = select_tokens
        if self._orders:
            order_tokens = SgExpression.ExtractTokensFromExpressions(self._orders[0])
            eval_exprs += order_tokens
        if self._having:
            having_tokens = SgExpression.ExtractTokensFromExpressions([self._having])
            eval_exprs += having_tokens
        if self._groups:
            eval_exprs += self._groups
        res_table = SgExpression.EvaluateExpressions(filtered_table, eval_exprs)

        # group by
        if self._groups:
            res_tables = SgGrouping.GenerateGroups(res_table, self._groups)
        else:
            res_tables = [res_table]
github lnishan / SQLGitHub / components / session.py View on Github external
def __init__(self, github, field_exprs, source, condition=None, groups=None, having=None, orders=None, limit=None):
        self._field_exprs = field_exprs
        self._source = source
        self._condition = condition
        self._groups = groups
        self._having = having
        self._orders = orders
        self._limit = limit

        rel_keys = SgExpression.ExtractTokensFromExpressions(self._field_exprs)
        if self._condition:
            rel_keys += SgExpression.ExtractTokensFromExpressions([self._condition])
        if self._groups:
            rel_keys += SgExpression.ExtractTokensFromExpressions(self._groups)
        if self._having:
            rel_keys += SgExpression.ExtractTokensFromExpressions([self._having])
        if self._orders:
            rel_keys += SgExpression.ExtractTokensFromExpressions(self._orders[0])
        rel_keys = list(set(rel_keys))
        self._fetcher = table_fetcher.SgTableFetcher(github, rel_keys)
github lnishan / SQLGitHub / components / session.py View on Github external
def __init__(self, github, field_exprs, source, condition=None, groups=None, having=None, orders=None, limit=None):
        self._field_exprs = field_exprs
        self._source = source
        self._condition = condition
        self._groups = groups
        self._having = having
        self._orders = orders
        self._limit = limit

        rel_keys = SgExpression.ExtractTokensFromExpressions(self._field_exprs)
        if self._condition:
            rel_keys += SgExpression.ExtractTokensFromExpressions([self._condition])
        if self._groups:
            rel_keys += SgExpression.ExtractTokensFromExpressions(self._groups)
        if self._having:
            rel_keys += SgExpression.ExtractTokensFromExpressions([self._having])
        if self._orders:
            rel_keys += SgExpression.ExtractTokensFromExpressions(self._orders[0])
        rel_keys = list(set(rel_keys))
        self._fetcher = table_fetcher.SgTableFetcher(github, rel_keys)
github lnishan / SQLGitHub / components / session.py View on Github external
filtered_table.SetFields(source_table.GetFields())
            meets = SgExpression.EvaluateExpression(source_table, self._condition)
            for i, row in enumerate(source_table):
                if meets[i]:
                    filtered_table.Append(row)
        else:
            filtered_table = source_table
        if not filtered_table[:]:
            return self._GetEmptyTable()
        
        # evaluate all necessary expressions
        # in reversed order because we process from the rightmost item first
        select_tokens = SgExpression.ExtractTokensFromExpressions(self._field_exprs[:]) 
        eval_exprs = select_tokens
        if self._orders:
            order_tokens = SgExpression.ExtractTokensFromExpressions(self._orders[0])
            eval_exprs += order_tokens
        if self._having:
            having_tokens = SgExpression.ExtractTokensFromExpressions([self._having])
            eval_exprs += having_tokens
        if self._groups:
            eval_exprs += self._groups
        res_table = SgExpression.EvaluateExpressions(filtered_table, eval_exprs)

        # group by
        if self._groups:
            res_tables = SgGrouping.GenerateGroups(res_table, self._groups)
        else:
            res_tables = [res_table]

        # having
        if self._having: