starrocks icon indicating copy to clipboard operation
starrocks copied to clipboard

[BugFix] forbid low cardinality optimization when cast string col to array<string>

Open packy92 opened this issue 7 months ago • 3 comments

Why I'm doing:

When cast a low cardinality string column to array type, the rewrite process mistakenly put it in dictdefine column. Actualy, we don't support a array data as a new dict column.

mysql> explain select cast(v3 as array<string>) from s4 limit 1;
+------------------------------------------------------------------------------------+
| Explain String                                                                     |
+------------------------------------------------------------------------------------+
| PLAN FRAGMENT 0                                                                    |
|  OUTPUT EXPRS:4: cast                                                              |
|   PARTITION: UNPARTITIONED                                                         |
|                                                                                    |
|   RESULT SINK                                                                      |
|                                                                                    |
|   3:Decode                                                                         |
|   |  <dict id 6> : <string id 4>                                                   |
|   |                                                                                |
|   2:EXCHANGE                                                                       |
|      limit: 1                                                                      |
|                                                                                    |
| PLAN FRAGMENT 1                                                                    |
|  OUTPUT EXPRS:                                                                     |
|   PARTITION: RANDOM                                                                |
|                                                                                    |
|   STREAM DATA SINK                                                                 |
|     EXCHANGE ID: 02                                                                |
|     UNPARTITIONED                                                                  |
|                                                                                    |
|   1:Project                                                                        |
|   |  <slot 6> : DictDefine(5: v3, [CAST(<place-holder> AS ARRAY<VARCHAR(65533)>)]) |
|   |  limit: 1                                                                      |
|   |                                                                                |
|   0:OlapScanNode                                                                   |
|      TABLE: s4                                                                     |
|      PREAGGREGATION: ON                                                            |
|      partitions=1/1                                                                |
|      rollup: s4                                                                    |
|      tabletRatio=10/10                                                             |
|      tabletList=47019,47021,47023,47025,47027,47029,47031,47033,47035,47037        |
|      cardinality=1                                                                 |
|      avgRowSize=33.0                                                               |
|      limit: 1                                                                      |
+------------------------------------------------------------------------------------+
34 rows in set (0.00 sec)

*** Aborted at 1719813268 (unix time) try "date -d @1719813268" if you are using GNU date ***
PC: @          0x81df29f starrocks::DictOptimizeParser::_eval_and_rewrite()
*** SIGSEGV (@0x180000002d) received by PID 4117232 (TID 0x7fee4a209640) from PID 45; stack trace: ***
    @          0xbf16c8a google::(anonymous namespace)::FailureSignalHandler()
    @     0x7fef3cc04bcb os::Linux::chained_handler()
    @     0x7fef3cc09a2d JVM_handle_linux_signal
    @     0x7fef3cbfd538 signalHandler()
    @     0x7fef3bd32520 (unknown)
    @          0x81df29f starrocks::DictOptimizeParser::_eval_and_rewrite()
    @          0x81e0a7f starrocks::DictOptimizeParser::eval_dict_expr()
    @          0x6fa9076 starrocks::pipeline::DictDecodeOperatorFactory::prepare()
    @          0x6d89dad starrocks::pipeline::NormalExecutionGroup::prepare_pipelines()
    @          0x51ed536 starrocks::pipeline::FragmentContext::prepare_all_pipelines()
    @          0x80eaaa6 starrocks::pipeline::FragmentExecutor::_prepare_pipeline_driver()
    @          0x80ee624 starrocks::pipeline::FragmentExecutor::prepare()
    @          0x822c526 starrocks::PInternalServiceImplBase<>::_exec_plan_fragment_by_pipeline()
    @          0x8232525 starrocks::PInternalServiceImplBase<>::_exec_plan_fragment()
    @          0x823c0c8 starrocks::PInternalServiceImplBase<>::_exec_plan_fragment()
    @          0x4f85dcd starrocks::PriorityThreadPool::work_thread()
    @          0xbec567b thread_proxy
    @     0x7fef3bd84ac3 (unknown)
    @     0x7fef3be16850 (unknown)
    @                0x0 (unknown)

What I'm doing:

forbid low cardinality optimization when cast string col to array Fixes #issue

What type of PR is this:

  • [x] BugFix
  • [ ] Feature
  • [ ] Enhancement
  • [ ] Refactor
  • [ ] UT
  • [ ] Doc
  • [ ] Tool

Does this PR entail a change in behavior?

  • [ ] Yes, this PR will result in a change in behavior.
  • [x] No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • [ ] Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • [ ] Parameter changes: default values, similar parameters but with different default values
  • [ ] Policy changes: use new policy to replace old one, functionality automatically enabled
  • [ ] Feature removed
  • [ ] Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • [x] I have added test cases for my bug fix or my new feature
  • [ ] This pr needs user documentation (for new or modified features or behaviors)
    • [ ] I have added documentation for my new feature or new function
  • [ ] This is a backport pr

Bugfix cherry-pick branch check:

  • [x] I have checked the version labels which the pr will be auto-backported to the target branch
    • [x] 3.3
    • [ ] 3.2
    • [ ] 3.1
    • [ ] 3.0
    • [ ] 2.5

packy92 avatar Jul 01 '24 06:07 packy92