def validate_column_name(expr: str) -> bool: """Check if `expr` is a valid column name. See :func:`~triad.utils.string.validate_triad_var_name` :param expr: column name expression :return: whether it is valid """ return validate_triad_var_name(expr)
def visitTableName(self, ctx: fp.TableNameContext) -> Iterable[Any]: table_name = self.ctxToStr(ctx.multipartIdentifier(), delimit="") if table_name not in self.variables: assert_or_throw( ctx.fugueDataFrameMember() is None, FugueSQLSyntaxError( "can't specify index or key for dataframe"), ) table: Any = self.hooks.on_select_source_not_found( self.workflow, table_name) else: table = self.get_df(table_name, ctx.fugueDataFrameMember()) if isinstance(table, str): yield table yield from self._get_query_elements(ctx.sample()) yield from self._get_query_elements(ctx.tableAlias()) else: yield table yield from self._get_query_elements(ctx.sample()) if ctx.tableAlias().strictIdentifier() is not None: yield from self._get_query_elements(ctx.tableAlias()) elif validate_triad_var_name(table_name): yield "AS" yield table_name
def _df_name_to_serialize_col(name: str): assert_or_throw(name is not None, "Dataframe name can't be None") name = "__blob__" + name + "__" assert_or_throw(validate_triad_var_name(name), "Invalid name " + name) return name