You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "Mine-Echo (via GitHub)" <gi...@apache.org> on 2025/01/03 09:16:10 UTC

[I] type error in convert_tbl_column_to_sqla_col [superset]

Mine-Echo opened a new issue, #31695:
URL: https://github.com/apache/superset/issues/31695

   ### 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](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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] type error in convert_tbl_column_to_sqla_col [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #31695:
URL: https://github.com/apache/superset/issues/31695#issuecomment-2840345914

   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!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] type error in convert_tbl_column_to_sqla_col [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #31695:
URL: https://github.com/apache/superset/issues/31695#issuecomment-4665720373

   The fix for this is already up in PR #31780 (thanks @Mine-Echo) and it just needs a maintainer review. @Mine-Echo, could you confirm this still reproduces on current master and rebase if needed? A small unit test asserting convert_tbl_column_to_sqla_col derives column_spec from tbl_column.type (not self.type) would also help it land. Flagging for review.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] type error in convert_tbl_column_to_sqla_col [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #31695:
URL: https://github.com/apache/superset/issues/31695#issuecomment-2568918630

   <!-- Answer -->
   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 <sup>[[1]](https://github.com/apache/superset/blob/master/superset/models/helpers.py)</sup>.
   
   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"](https://github.com/apache/superset/discussions/31680) <sup>[[2]](https://github.com/apache/superset/discussions/31680)</sup>.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   
   ---
   <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/3e9934bb-e341-4f0a-a677-5d8e1175dbe5?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/3e9934bb-e341-4f0a-a677-5d8e1175dbe5?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/3e9934bb-e341-4f0a-a677-5d8e1175dbe5?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/3e9934bb-e341-4f0a-a677-5d8e1175dbe5?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/3e9934bb-e341-4f0a-a677-5d8e1175dbe5?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/3e9934bb-e341-4f0a-a677-5d8e1175dbe5?feedback_type=other)</sup>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] type error in convert_tbl_column_to_sqla_col [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas closed issue #31695: type error in convert_tbl_column_to_sqla_col
URL: https://github.com/apache/superset/issues/31695


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] type error in convert_tbl_column_to_sqla_col [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #31695:
URL: https://github.com/apache/superset/issues/31695#issuecomment-4702257002

   Looks like #31780 fixed this in convert_tbl_column_to_sqla_col when it merged - closing, but ping me to reopen if you still hit it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] type error in convert_tbl_column_to_sqla_col [superset]

Posted by "Mine-Echo (via GitHub)" <gi...@apache.org>.
Mine-Echo commented on issue #31695:
URL: https://github.com/apache/superset/issues/31695#issuecomment-2568920783

   The discussion is opened by me


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] type error in convert_tbl_column_to_sqla_col [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #31695:
URL: https://github.com/apache/superset/issues/31695#issuecomment-3271578145

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org