Bug description

function convert_tbl_column_to_sqla_col is at superset/models/helpers.py https://github.com/apache/superset/blob/master/superset/models/helpers.py#L1403

    def convert_tbl_column_to_sqla_col(
        self,
        tbl_column: "TableColumn",
        label: Optional[str] = None,
        template_processor: Optional[BaseTemplateProcessor] = None,
    ) -> Column:
        label = label or tbl_column.column_name
        db_engine_spec = self.db_engine_spec
        column_spec = db_engine_spec.get_column_spec(self.type, db_extra=self.db_extra)
        type_ = column_spec.sqla_type if column_spec else None
        if expression := tbl_column.expression:
            if template_processor:
                expression = template_processor.process_template(expression)
            col = literal_column(expression, type_=type_)
        else:
            col = sa.column(tbl_column.column_name, type_=type_)
        col = self.make_sqla_column_compatible(col, label)
        return col

why here use self.type but not tbl.column? I think the latter is right. column_spec = db_engine_spec.get_column_spec(self.type, db_extra=self.db_extra) When debugging, I found self,type is "table", then column_spec will be None. I think self.type is not native type of the column, here we should pass tal_column. type, which is "IPADDR" in my case. After I modify this, I successfully processed data types by literal_processor while using filters. For example, I process "127.0.0.1" to "ipaddr(\"127.0.0.1\")" when filtering. Is this really a bug in superset? Or did I just understand it wrong somewhere?

Screenshots/recordings

No response

Superset version

master / latest-dev

Python version

3.11

Node version

16

Browser

Chrome

Additional context

No response

Checklist

  • [X] I have searched Superset docs and Slack and didn't find a solution to my problem.
  • [X] I have searched the GitHub issue tracker and didn't find a similar bug report.
  • [X] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.

Comment From: dosubot[bot]

The issue you're encountering with the convert_tbl_column_to_sqla_col function, where self.type is used instead of tbl_column.type, does appear to be a bug. The use of self.type results in None for column_spec, which is not the intended behavior. Changing it to tbl_column.type resolves the issue by correctly using the type of the table column being converted [1].

There is a similar unsolved discussion on this topic, which you might find relevant: Why use self.type in function "convert_tbl_column_to_sqla_col" [2].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

Comment From: Mine-Echo

The discussion is opened by me

Comment From: rusackas

Sorry this slipped under the radar. Let's see if we can get the CI to pass on your PR (thank you for that) and get it merged!

Comment From: rusackas

Running CI on the PR (again), but it would be good if you can confirm this is indeed still an issue on latest master.