示例#1
0
 def _sql(
     self, code: str, *args: Any, **kwargs: Any
 ) -> Dict[str, Tuple[WorkflowDataFrame, WorkflowDataFrames,
                      LazyWorkflowDataFrame]]:
     # TODO: move dict construction to triad
     params: Dict[str, Any] = {}
     for a in args:
         assert_or_throw(isinstance(a, Dict),
                         lambda: f"args can only have dict: {a}")
         params.update(a)
     params.update(kwargs)
     params, dfs = self._split_params(params)
     code = fill_sql_template(code, params)
     sql = FugueSQL(
         code,
         "fugueLanguage",
         ignore_case=self.conf.get_or_throw(FUGUE_SQL_CONF_IGNORE_CASE,
                                            bool),
         simple_assign=self.conf.get_or_throw(FUGUE_SQL_CONF_SIMPLE_ASSIGN,
                                              bool),
     )
     v = _Extensions(
         sql,
         FugueSQLHooks(),
         self,
         dfs,
         local_vars=params  # type: ignore
     )
     v.visit(sql.tree)
     return v.variables
示例#2
0
 def _sql(self, code: str, *args: Any,
          **kwargs: Any) -> Dict[str, WorkflowDataFrame]:
     # TODO: move dict construction to triad
     params: Dict[str, Any] = {}
     for a in args:
         assert_or_throw(isinstance(a, Dict),
                         f"args can only have dict: {a}")
         params.update(a)
     params.update(kwargs)
     template_params = dict(params)
     if "self" in template_params:
         del template_params["self"]
     code = fill_sql_template(code, template_params)
     sql = FugueSQL(
         code,
         "fugueLanguage",
         ignore_case=self.conf.get_or_throw(FUGUE_SQL_CONF_IGNORE_CASE,
                                            bool),
         simple_assign=self.conf.get_or_throw(FUGUE_SQL_CONF_SIMPLE_ASSIGN,
                                              bool),
     )
     dfs = {
         k: v
         for k, v in params.items() if isinstance(v, WorkflowDataFrame)
     }
     v = _Extensions(sql, FugueSQLHooks(), self, dfs, local_vars=params)
     v.visit(sql.tree)
     return v.variables
示例#3
0
 def _sql(self, code: str, *args: Any,
          **kwargs: Any) -> Dict[str, WorkflowDataFrame]:
     # TODO: move dict construction to triad
     params: Dict[str, Any] = {}
     for a in args:
         assert_or_throw(isinstance(a, Dict),
                         f"args can only have dict: {a}")
         params.update(a)
     params.update(kwargs)
     code = fill_sql_template(code, params)
     sql = FugueSQL(
         code,
         "fugueLanguage",
         ignore_case=self.conf.get_or_throw("fugue.sql.compile.ignore_case",
                                            bool),
         simple_assign=self.conf.get_or_throw(
             "fugue.sql.compile.simple_assign", bool),
     )
     dfs = {
         k: v
         for k, v in params.items() if isinstance(v, WorkflowDataFrame)
     }
     v = _Extensions(sql, FugueSQLHooks(), self, dfs)
     v.visit(sql.tree)
     return v.variables
示例#4
0
def assert_eq(expr, expected: FugueWorkflow):
    global_vars, local_vars = get_caller_global_local_vars()
    sql = FugueSQL(expr, "fugueLanguage", ignore_case=True, simple_assign=True)
    wf = FugueWorkflow()
    v = _Extensions(
        sql, FugueSQLHooks(), wf, global_vars=global_vars, local_vars=local_vars
    )
    obj = v.visit(sql.tree)
    assert expected.spec_uuid() == v.workflow.spec_uuid()
示例#5
0
def assert_eq(expr, expected: FugueWorkflow):
    sql = FugueSQL(expr, "fugueLanguage", ignore_case=True, simple_assign=True)
    wf = FugueWorkflow()
    v = _Extensions(sql, FugueSQLHooks(), wf)
    obj = v.visit(sql.tree)
    assert expected.spec_uuid() == v.workflow.spec_uuid()