pingcap / tiflash

The analytical engine for TiDB and TiDB Cloud. Try free: https://tidbcloud.com/free-trial
https://docs.pingcap.com/tidb/stable/tiflash-overview
Apache License 2.0
946 stars 409 forks source link

build PhysicalExchangeSender cause Block schema mismatch #8111

Closed Lloyd-Pottiger closed 1 year ago

Lloyd-Pottiger commented 1 year ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create database if not exists `retail_fas`; use `retail_fas`;CREATE TABLE `fcs_reserve_cash_init` (
  `id` char(32) NOT NULL,
  `store_no` varchar(10) NOT NULL,
  `amount` decimal(8,2) NOT NULL DEFAULT '0.00',
  `bill_type` tinyint(3) NOT NULL DEFAULT '1',
  `nc_bill_date` date DEFAULT NULL,
  PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
  KEY `idx_store_no` (`store_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

create database if not exists `retail_fas`; use `retail_fas`;CREATE TABLE `fcs_cash_diff_month_report` (
  `id` char(32) NOT NULL,
  `store_no` varchar(10) NOT NULL,
  `year_month` date NOT NULL,
  `amount` decimal(8,2) NOT NULL,
  PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
  UNIQUE KEY `udx_ys` (`year_month`,`store_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

create database if not exists `retail_fas`; use `retail_fas`;CREATE TABLE `fcs_reserve_cash_month_report` (
  `id` char(32) NOT NULL,
  `store_no` varchar(10) NOT NULL,
  `year_month` date NOT NULL,
  `amount` decimal(8,2) NOT NULL DEFAULT '0.00',
  PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
  UNIQUE KEY `udx_ys` (`year_month`,`store_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

alter database retail_fas set tiflash replica 1;

set tidb_cost_model_version=1;

set session sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

SELECT SUM(receive_amount), SUM(total_diff_amount)
FROM (
    SELECT SUM(IF(bill_type = 2, amount, 0)) AS receive_amount, 0.0 AS total_diff_amount
    FROM retail_fas.fcs_reserve_cash_init
    WHERE nc_bill_date <= '2023-09-12 00:00:00.0'
    GROUP BY store_no
    UNION ALL
    SELECT 0.0 AS receive_amount, 0.0 AS total_diff_amount
    FROM retail_fas.fcs_reserve_cash_month_report
    WHERE `year_month` = '2023-09-12 00:00:00.0'
    UNION ALL
    SELECT 0.0 AS receive_amount, amount AS total_diff_amount
    FROM retail_fas.fcs_cash_diff_month_report
    WHERE `year_month` = '2023-09-12 00:00:00.0'
) temp
GROUP BY receive_amount;
[2023/09/18 19:03:43.528 +08:00] [DEBUG] [MPPTask.cpp:517] ["task starts preprocessing"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.528 +08:00] [DEBUG] [MPPTask.cpp:472] ["init exchange receiver done"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.528 +08:00] [DEBUG] [executeQuery.cpp:398] ["(from 127.0.0.1:49912, query_id: 7660ec54-b8e2-4405-9c72-a3e794013c65) time_zone_offset: 28800 flags: 226 output_offsets: 0 output_offsets: 1 encode_type: TypeCHBlock time_zone_name: \"Asia/Shanghai\" collect_execution_summaries: true chunk_memory_layout {   endian: LittleEndian } root_executor {   tp: TypeExchangeSender   executor_id: \"ExchangeSender_116\"   exchange_sender {     tp: Hash     encoded_task_meta: \"\\010\\201\\200\\300\\211\\370\\372\\247\\225\\006\\020\\005\\\"\\016127.0.0.1:3930(\\0010\\353\\323\\252\\325\\370\\253\\376\\302\\0278\\003@\\262\\010H\\002\"     partition_keys {       tp: ColumnRef       val: \"\\200\\000\\000\\000\\000\\000\\000\\000\"       sig: Unspecified       field_type {         tp: 246         flag: 128         flen: 30         decimal: 2         collate: -63         charset: \"binary\"       }       has_distinct: false     }     child {       tp: TypeProjection       executor_id: \"Projection_111\"       Projection {         exprs {           tp: MysqlDecimal           val: \"\\002\\002\\200\"           sig: Unspecified           field_type {             tp: 246             flag: 128             flen: 30             decimal: 2             collate: -63             charset: \"binary\"           }           has_distinct: false         }         exprs {           tp: MysqlDecimal           val: \"\\002\\002\\200\"           sig: Unspecified           field_type {             tp: 246             flag: 128             flen: 8             decimal: 2             collate: -63             charset: \"binary\"           }           has_distinct: false         }         child {           tp: TypeSelection           selection {             conditions {               tp: ScalarFunc               children {                 tp: ColumnRef                 val: \"\\200\\000\\000\\000\\000\\000\\000\\000\"                 sig: Unspecified                 field_type {                   tp: 10                   flag: 4233                   flen: 10                   decimal: 0                   collate: -63                   charset: \"binary\"                 }                 has_distinct: false               }               children {                 tp: MysqlTime                 val: \"\\031\\261\\030\\000\\000\\000\\000\\000\"                 sig: Unspecified                 field_type {                   tp: 12                   flag: 129                   flen: 26                   decimal: 6                   collate: -63                   charset: \"binary\"                 }                 has_distinct: false               }               sig: EQTime               field_type {                 tp: 8                 flag: 524416                 flen: 1                 decimal: 0                 collate: -63                 charset: \"binary\"               }               has_distinct: false             }             child {               tp: TypeTableScan               tbl_scan {                 table_id: 106                 columns {                   column_id: 6                   tp: 10                   collation: -63                   columnLen: 10                   decimal: 0                   flag: 4233                   pk_handle: false                 }                 desc: false                 primary_column_ids: 1                 next_read_engine: Local                 keep_order: false                 is_fast_scan: false                 max_wait_time_ms: 0               }               executor_id: \"TableFullScan_89\"               fine_grained_shuffle_stream_count: 0               fine_grained_shuffle_batch_size: 0             }           }           executor_id: \"Selection_90\"           fine_grained_shuffle_stream_count: 0           fine_grained_shuffle_batch_size: 0         }       }       fine_grained_shuffle_stream_count: 0       fine_grained_shuffle_batch_size: 0     }     types {       tp: 246       flag: 128       flen: 30       decimal: 2       collate: -63       charset: \"binary\"     }     all_field_types {       tp: 246       flag: 128       flen: 30       decimal: 2       collate: -63       charset: \"binary\"     }     all_field_types {       tp: 246       flag: 128       flen: 8       decimal: 2       collate: -63       charset: \"binary\"     }     compression: FAST   }   fine_grained_shuffle_stream_count: 36   fine_grained_shuffle_batch_size: 8192 } "] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.529 +08:00] [DEBUG] [PhysicalPlan.cpp:84] ["tidb table scan has runtime filter size:0"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.532 +08:00] [DEBUG] [PhysicalPlan.cpp:299] ["build unoptimized physical plan: \n<ExchangeSender, ExchangeSender_116> | is_tidb_operator: true, schema: <ExchangeSender_116_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0 , Nullable(Decimal(30,2))>, <ExchangeSender_116_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0 _1, Nullable(Decimal(30,2))>\n <Projection, Projection_111> | is_tidb_operator: false, schema: <ExchangeSender_116_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0 , Nullable(Decimal(30,2))>, <ExchangeSender_116_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0 _1, Nullable(Decimal(30,2))>\n  <Projection, Projection_111> | is_tidb_operator: true, schema: <0.00_Decimal(2,2), Decimal(2,2)>, <0.00_Decimal(2,2), Decimal(2,2)>\n   <TableScan, TableFullScan_89> | is_tidb_operator: true, schema: <table_scan_0, MyDate>\n"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.533 +08:00] [DEBUG] [PhysicalPlan.cpp:302] ["build optimized physical plan: \n<ExchangeSender, ExchangeSender_116> | is_tidb_operator: true, schema: <ExchangeSender_116_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0 , Nullable(Decimal(30,2))>, <ExchangeSender_116_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0 _1, Nullable(Decimal(30,2))>\n <Projection, Projection_111> | is_tidb_operator: false, schema: <ExchangeSender_116_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0 , Nullable(Decimal(30,2))>, <ExchangeSender_116_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0 _1, Nullable(Decimal(30,2))>\n  <Projection, Projection_111> | is_tidb_operator: true, schema: <0.00_Decimal(2,2), Decimal(2,2)>, <0.00_Decimal(2,2), Decimal(2,2)>\n   <TableScan, TableFullScan_89> | is_tidb_operator: true, schema: <table_scan_0, MyDate>\n"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.536 +08:00] [DEBUG] [LearnerRead.cpp:397] ["Batch read index, original size 1, send & get 1 message, cost 2ms"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.536 +08:00] [DEBUG] [LearnerRead.cpp:505] ["Finish wait index | resolve locks, wait_cost=0ms n_regions=1 n_unavailable=0"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.536 +08:00] [DEBUG] [LearnerRead.cpp:530] ["[Learner Read] batch read index | wait index total_cost=2 read_cost=2 wait_cost=0 n_regions=1 n_stale_read=0 n_unavailable=0"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.536 +08:00] [INFO] [DAGStorageInterpreter.cpp:1417] ["OK, no syncing required."] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.537 +08:00] [DEBUG] [StorageDeltaMerge.cpp:678] ["Read with tso: 444343261183606785"] [source="db_98.t_106 MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3> table_id=106"] [thread_id=337]
[2023/09/18 19:03:43.537 +08:00] [DEBUG] [StorageDeltaMerge.cpp:759] ["Rough set filter: {\"op\":\"equal\",\"col\":\"year_month\",\"value\":\"1851287310105051136\"}"] [source="db_98.t_106 MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3> table_id=106"] [thread_id=337]
[2023/09/18 19:03:43.537 +08:00] [DEBUG] [StorageDeltaMerge.cpp:777] ["Push down filter is empty"] [source="db_98.t_106 MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3> table_id=106"] [thread_id=337]
[2023/09/18 19:03:43.537 +08:00] [DEBUG] [StorageDeltaMerge.cpp:1015] ["build runtime filter in local stream, list size:0"] [source=db_98.t_106] [thread_id=337]
[2023/09/18 19:03:43.537 +08:00] [INFO] [DeltaMergeStore.cpp:1176] ["Read create segment snapshot done, keep_order=false dt_enable_read_thread=true enable_read_thread=true is_fast_scan=false is_push_down_filter_empty=true"] [source="keyspace=4294967295 table_id=106 MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3> table_id=106"] [thread_id=337]
[2023/09/18 19:03:43.537 +08:00] [DEBUG] [UnorderedInputStream.h:46] ["Created, pool_id=4 ref_no=0"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3> table_id=106"] [thread_id=337]
[2023/09/18 19:03:43.537 +08:00] [DEBUG] [DeltaMergeStore.cpp:1232] ["Read create stream done"] [source="keyspace=4294967295 table_id=106 MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3> table_id=106"] [thread_id=337]
[2023/09/18 19:03:43.537 +08:00] [DEBUG] [DAGStorageInterpreter.cpp:1199] ["local streams built, is_disaggregated_task=false snap_id=DisTaskId<MPP<gather_id:<gather_id:0, query_ts:0, local_query_id:0, server_id:0, start_ts:0, resource_gorup: >,task_id:0>,executor=>"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.539 +08:00] [DEBUG] [DAGStorageInterpreter.cpp:1538] ["remote request size: 0"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.539 +08:00] [INFO] [executeQuery.cpp:425] ["Query pipeline:\nExchangeSender: <enable fine grained shuffle>\n Expression: <final projection>\n  Expression: <projection>\n   Expression: <table scan schema projection>\n    Expression: <projection after push down filter>\n     Filter: <push down filter>\n      UnorderedInputStream\n"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.540 +08:00] [DEBUG] [MPPTask.cpp:474] ["init query executor done"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.540 +08:00] [DEBUG] [MPPTask.cpp:520] ["task preprocess done"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.540 +08:00] [DEBUG] [MPPTask.cpp:527] ["Estimate new thread count of query: 2 including tunnel_threads: 0, receiver_threads: 0"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.540 +08:00] [DEBUG] [MinTSOScheduler.cpp:391] ["min_query_id query is updated from <query_ts:18446744073709551615, local_query_id:18446744073709551615, server_id:18446744073709551615, start_ts:18446744073709551615, resource_group: > to <query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_group: > when directly schedule it, used threads = 0, 0 active and 0 waiting queries."] [thread_id=337]
[2023/09/18 19:03:43.540 +08:00] [DEBUG] [MPPTaskScheduleEntry.cpp:49] ["task is scheduled."] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.540 +08:00] [DEBUG] [MinTSOScheduler.cpp:301] ["MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3> is scheduled (active set size = 1) due to available threads directly, after applied for 2 threads, used 2 of the thread hard limit 10000."] [thread_id=337]
[2023/09/18 19:03:43.540 +08:00] [INFO] [MPPTask.cpp:536] ["task starts running, time cost in schedule: 0 ms, time cost in preprocess: 12 ms"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.541 +08:00] [ERROR] [FineGrainedShuffleWriter.cpp:63] ["sample_block columns size: 2, block structure: ExchangeSender_116_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0  0 Nullable(Decimal(30,2)) Const(size = 0, Nullable(size = 1, Decimal128(size = 1), UInt8(size = 1))), ExchangeSender_116_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0 _1 0 Nullable(Decimal(30,2)) Const(size = 0, Nullable(size = 1, Decimal128(size = 1), UInt8(size = 1)))"] [thread_id=337]
[2023/09/18 19:03:43.544 +08:00] [ERROR] [FineGrainedShuffleWriter.cpp:77] ["header columns size: 2, block structure: ExchangeSender_116_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0  0 Nullable(Decimal(30,2)) Nullable(size = 0, Decimal128(size = 0), UInt8(size = 0)), ExchangeSender_116_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0 _1 0 Nullable(Decimal(30,2)) Nullable(size = 0, Decimal128(size = 0), UInt8(size = 0))"] [thread_id=337]
[2023/09/18 19:03:43.545 +08:00] [DEBUG] [FineGrainedShuffleWriter.cpp:93] ["expected types: Nullable(Decimal(30,2))Nullable(Decimal(8,2))"] [thread_id=337]
[2023/09/18 19:03:43.545 +08:00] [ERROR] [DAGUtils.cpp:707] ["columns size: 2, block structure: ExchangeSender_116_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0  0 Nullable(Decimal(30,2)) Nullable(size = 0, Decimal128(size = 0), UInt8(size = 0)), ExchangeSender_116_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0 _1 0 Nullable(Decimal(30,2)) Nullable(size = 0, Decimal128(size = 0), UInt8(size = 0))"] [thread_id=337]
[2023/09/18 19:03:43.545 +08:00] [INFO] [MPPTask.cpp:559] ["mpp task finish execute, success: false"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.545 +08:00] [INFO] [MPPTask.cpp:577] ["mpp finish with request unit: cpu=0 read=0"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.545 +08:00] [DEBUG] [MPPTask.cpp:590] ["finish with 0 seconds, 0 rows, 0 blocks, 0 bytes"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.551 +08:00] [ERROR] [MPPTask.cpp:627] ["task running meets error: Code: 0, e.displayText() = DB::Exception: Block column ExchangeSender_116_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0 _1 schema mismatch in FineGrainedShuffleWriter-V1: different types: expected Nullable(Decimal(8,2)), got Nullable(Decimal(30,2)), e.what() = DB::Exception, Stack trace:\n\n\n  0x56421a45cc9e\tStackTrace::StackTrace() [tiflash+69733534]\n                \tdbms/src/Common/StackTrace.cpp:23\n  0x56421a44c7d2\tDB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) [tiflash+69666770]\n                \tdbms/src/Common/Exception.h:46\n  0x564224253a2c\tvoid DB::(anonymous namespace)::assertBlockSchema<DB::assertBlockSchema(std::__1::vector<std::__1::shared_ptr<DB::IDataType const>, std::__1::allocator<std::__1::shared_ptr<DB::IDataType const> > > const&, DB::Block const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_2, DB::assertBlockSchema(std::__1::vector<std::__1::shared_ptr<DB::IDataType const>, std::__1::allocator<std::__1::shared_ptr<DB::IDataType const> > > const&, DB::Block const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_3>(DB::assertBlockSchema(std::__1::vector<std::__1::shared_ptr<DB::IDataType const>, std::__1::allocator<std::__1::shared_ptr<DB::IDataType const> > > const&, DB::Block const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_2&&, DB::assertBlockSchema(std::__1::vector<std::__1::shared_ptr<DB::IDataType const>, std::__1::allocator<std::__1::shared_ptr<DB::IDataType const> > > const&, DB::Block const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_3&&, DB::Block const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) [tiflash+235371052]\n                \tdbms/src/Flash/Coprocessor/DAGUtils.cpp:716\n  0x5642242530e9\tDB::assertBlockSchema(std::__1::vector<std::__1::shared_ptr<DB::IDataType const>, std::__1::allocator<std::__1::shared_ptr<DB::IDataType const> > > const&, DB::Block const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) [tiflash+235368681]\n                \tdbms/src/Flash/Coprocessor/DAGUtils.cpp:1440\n  0x564224539168\tDB::FineGrainedShuffleWriter<std::__1::shared_ptr<DB::SyncMPPTunnelSetWriter> >::prepare(DB::Block const&) [tiflash+238408040]\n                \tdbms/src/Flash/Mpp/FineGrainedShuffleWriter.cpp:95\n  0x5642243b481b\tDB::ExchangeSenderBlockInputStream::readPrefixImpl() [tiflash+236816411]\n                \tdbms/src/DataStreams/ExchangeSenderBlockInputStream.h:43\n  0x5642225b9375\tDB::IProfilingBlockInputStream::readPrefix() [tiflash+205378421]\n                \tdbms/src/DataStreams/IProfilingBlockInputStream.cpp:131\n  0x564224548328\tDB::DataStreamExecutor::execute(DB::ResultHandler&&) [tiflash+238469928]\n                \tdbms/src/Flash/Executor/DataStreamExecutor.cpp:41\n  0x564224558507\tDB::QueryExecutor::execute() [tiflash+238535943]\n                \tdbms/src/Flash/Executor/QueryExecutor.cpp:29\n  0x5642244852ab\tDB::MPPTask::runImpl() [tiflash+237671083]\n                \tdbms/src/Flash/Mpp/MPPTask.cpp:558\n  0x56422448a01d\tDB::MPPTask::run()::$_19::operator()() const [tiflash+237690909]\n                \tdbms/src/Flash/Mpp/MPPTask.cpp:197\n  0x564224489ff5\tdecltype(std::declval<DB::MPPTask::run()::$_19&>()()) std::__1::__invoke[abi:v15007]<DB::MPPTask::run()::$_19&>(DB::MPPTask::run()::$_19&) [tiflash+237690869]\n                \t/usr/local/bin/../include/c++/v1/__functional/invoke.h:394\n  0x564224489fb5\tvoid std::__1::__invoke_void_return_wrapper<void, true>::__call<DB::MPPTask::run()::$_19&>(DB::MPPTask::run()::$_19&) [tiflash+237690805]\n                \t/usr/local/bin/../include/c++/v1/__functional/invoke.h:479\n  0x564224489f8d\tstd::__1::__function::__alloc_func<DB::MPPTask::run()::$_19, std::__1::allocator<DB::MPPTask::run()::$_19>, void ()>::operator()[abi:v15007]() [tiflash+237690765]\n                \t/usr/local/bin/../include/c++/v1/__functional/function.h:185\n  0x564224489289\tstd::__1::__function::__func<DB::MPPTask::run()::$_19, std::__1::allocator<DB::MPPTask::run()::$_19>, void ()>::operator()() [tiflash+237687433]\n                \t/usr/local/bin/../include/c++/v1/__functional/function.h:359\n  0x56421a579ba2\tstd::__1::__function::__value_func<void ()>::operator()[abi:v15007]() const [tiflash+70900642]\n                \t/usr/local/bin/../include/c++/v1/__functional/function.h:512\n  0x56421a56eff5\tstd::__1::function<void ()>::operator()() const [tiflash+70856693]\n                \t/usr/local/bin/../include/c++/v1/__functional/function.h:1197\n  0x564222930b85\tdecltype(std::declval<std::__1::function<void ()> >()()) std::__1::__invoke[abi:v15007]<std::__1::function<void ()> >(std::__1::function<void ()>&&) [tiflash+209013637]\n                \t/usr/local/bin/../include/c++/v1/__functional/invoke.h:394\n  0x564222930b69\tdecltype(auto) std::__1::__apply_tuple_impl[abi:v15007]<std::__1::function<void ()>, std::__1::tuple<> >(std::__1::function<void ()>&&, std::__1::tuple<>&&, std::__1::__tuple_indices<>) [tiflash+209013609]\n                \t/usr/local/bin/../include/c++/v1/tuple:1789\n  0x564222930b3d\tdecltype(auto) std::__1::apply[abi:v15007]<std::__1::function<void ()>, std::__1::tuple<> >(std::__1::function<void ()>&&, std::__1::tuple<>&&) [tiflash+209013565]\n                \t/usr/local/bin/../include/c++/v1/tuple:1798\n  0x564222930aeb\tauto DB::wrapInvocable<std::__1::function<void ()> >(bool, std::__1::function<void ()>&&)::'lambda'()::operator()() [tiflash+209013483]\n                \tdbms/src/Common/wrapInvocable.h:36\n  0x5642229314b9\tDB::ExecutableTask<auto DB::wrapInvocable<std::__1::function<void ()> >(bool, std::__1::function<void ()>&&)::'lambda'()>::execute() [tiflash+209015993]\n                \tdbms/src/Common/ExecutableTask.h:50\n  0x56421a5c6c78\tDB::DynamicThreadPool::executeTask(std::__1::unique_ptr<DB::IExecutableTask, std::__1::default_delete<DB::IExecutableTask> >&) [tiflash+71216248]\n                \tdbms/src/Common/DynamicThreadPool.cpp:124\n  0x56421a5c690d\tDB::DynamicThreadPool::fixedWork(unsigned long) [tiflash+71215373]\n                \tdbms/src/Common/DynamicThreadPool.cpp:138\n  0x56421a5d0754\tdecltype(*(std::declval<DB::DynamicThreadPool*>()).*std::declval<void (DB::DynamicThreadPool::* const&)(unsigned long)>()(std::declval<unsigned long&>())) std::__1::__invoke[abi:v15007]<void (DB::DynamicThreadPool::* const&)(unsigned long), DB::DynamicThreadPool*, unsigned long&, void>(void (DB::DynamicThreadPool::* const&)(unsigned long), DB::DynamicThreadPool*&&, unsigned long&) [tiflash+71255892]\n                \t/usr/local/bin/../include/c++/v1/__functional/invoke.h:359\n  0x56421a5d0695\tstd::__1::invoke_result<void (DB::DynamicThreadPool::* const&)(unsigned long), DB::DynamicThreadPool*, unsigned long&>::type std::__1::invoke<void (DB::DynamicThreadPool::* const&)(unsigned long), DB::DynamicThreadPool*, unsigned long&>(void (DB::DynamicThreadPool::* const&)(unsigned long), DB::DynamicThreadPool*&&, unsigned long&) [tiflash+71255701]\n                \t/usr/local/bin/../include/c++/v1/__functional/invoke.h:531\n  0x56421a5d0606\tauto std::__1::thread DB::ThreadFactory::newThread<void (DB::DynamicThreadPool::*)(unsigned long), DB::DynamicThreadPool*, unsigned long&>(bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void (DB::DynamicThreadPool::*&&)(unsigned long), DB::DynamicThreadPool*&&, unsigned long&)::'lambda'(auto&&...)::operator()<DB::DynamicThreadPool*, unsigned long>(auto&&...) const [tiflash+71255558]\n                \tdbms/src/Common/ThreadFactory.h:48\n  0x56421a5d0435\tdecltype(std::declval<void (DB::DynamicThreadPool::*)(unsigned long)>()(std::declval<DB::DynamicThreadPool*>(), std::declval<unsigned long&>())) std::__1::__invoke[abi:v15007]<std::__1::thread DB::ThreadFactory::newThread<void (DB::DynamicThreadPool::*)(unsigned long), DB::DynamicThreadPool*, unsigned long&>(bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void (DB::DynamicThreadPool::*&&)(unsigned long), DB::DynamicThreadPool*&&, unsigned long&)::'lambda'(auto&&...), DB::DynamicThreadPool*, unsigned long>(void (DB::DynamicThreadPool::*&&)(unsigned long), DB::DynamicThreadPool*&&, unsigned long&) [tiflash+71255093]\n                \t/usr/local/bin/../include/c++/v1/__functional/invoke.h:394\n  0x56421a5d03ff\tvoid std::__1::__thread_execute[abi:v15007]<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, std::__1::thread DB::ThreadFactory::newThread<void (DB::DynamicThreadPool::*)(unsigned long), DB::DynamicThreadPool*, unsigned long&>(bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void (DB::DynamicThreadPool::*&&)(unsigned long), DB::DynamicThreadPool*&&, unsigned long&)::'lambda'(auto&&...), DB::DynamicThreadPool*, unsigned long, 2ul, 3ul>(std::__1::tuple<void (DB::DynamicThreadPool::*)(unsigned long), std::__1::thread DB::ThreadFactory::newThread<void (DB::DynamicThreadPool::*)(unsigned long), DB::DynamicThreadPool*, unsigned long&>(bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void (DB::DynamicThreadPool::*&&)(unsigned long), DB::DynamicThreadPool*&&, unsigned long&)::'lambda'(auto&&...), DB::DynamicThreadPool*, unsigned long>&, std::__1::__tuple_indices<2ul, 3ul>) [tiflash+71255039]\n                \t/usr/local/bin/../include/c++/v1/thread:284\n  0x56421a5d0132\tvoid* std::__1::__thread_proxy[abi:v15007]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, std::__1::thread DB::ThreadFactory::newThread<void (DB::DynamicThreadPool::*)(unsigned long), DB::DynamicThreadPool*, unsigned long&>(bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void (DB::DynamicThreadPool::*&&)(unsigned long), DB::DynamicThreadPool*&&, unsigned long&)::'lambda'(auto&&...), DB::DynamicThreadPool*, unsigned long> >(void*) [tiflash+71254322]\n                \t/usr/local/bin/../include/c++/v1/thread:295\n  0x7f1b0a3db802\tstart_thread [libc.so.6+653314]\n  0x7f1b0a37b450\tclone3 [libc.so.6+259152]"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.553 +08:00] [WARN] [MPPTask.cpp:725] ["Begin abort task: MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>, abort type: ONERROR"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.553 +08:00] [WARN] [ExchangeReceiver.cpp:982] ["connection end. meet error: true, err msg: Code: 0, e.displayText() = DB::Exception: Block column ExchangeSender_116_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0 _1 schema mismatch in FineGrainedShuffleWriter-V1: different types: expected Nullable(Decimal(8,2)), got Nullable(Decimal(30,2)), e.what() = DB::Exception,, current alive connections: 1"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:5> ExchangeReceiver_117 local tunnel3+5"] [thread_id=337]
[2023/09/18 19:03:43.553 +08:00] [WARN] [ExchangeReceiver.cpp:1003] ["Finish receiver channels, meet error: true, error message: Code: 0, e.displayText() = DB::Exception: Block column ExchangeSender_116_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0 _1 schema mismatch in FineGrainedShuffleWriter-V1: different types: expected Nullable(Decimal(8,2)), got Nullable(Decimal(30,2)), e.what() = DB::Exception,"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:5> ExchangeReceiver_117"] [thread_id=337]
[2023/09/18 19:03:43.553 +08:00] [INFO] [MPPTunnel.h:361] ["connection for tunnel3+5 cost 22 ms, including 0 ms to wait task."] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3> tunnel3+5"] [thread_id=337]
[2023/09/18 19:03:43.553 +08:00] [WARN] [MPPTask.cpp:754] ["Finish abort task from running"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.553 +08:00] [INFO] [MPPTaskStatistics.cpp:136] ["{\"query_tso\":444343261183606785,\"task_id\":3,\"is_root\":false,\"sender_executor_id\":\"ExchangeSender_116\",\"executors\":[{\"id\":\"ExchangeSender_116\",\"type\":\"ExchangeSender\",\"children\":[\"Projection_111\"],\"outbound_rows\":0,\"outbound_blocks\":0,\"outbound_bytes\":0,\"outbound_allocated_bytes\":0,\"execution_time_ns\":0,\"partition_num\":1,\"sender_target_task_ids\":[5],\"exchange_type\":\"Hash\",\"connection_details\":[{\"tunnel_id\":\"tunnel3+5\",\"sender_target_task_id\":5,\"sender_target_host\":\"127.0.0.1:3930\",\"is_local\":true,\"packets\":0,\"bytes\":0}]},{\"id\":\"Projection_111\",\"type\":\"Projection\",\"children\":[\"Selection_90\"],\"outbound_rows\":0,\"outbound_blocks\":0,\"outbound_bytes\":0,\"outbound_allocated_bytes\":0,\"execution_time_ns\":0},{\"id\":\"Selection_90\",\"type\":\"Selection\",\"children\":[\"TableFullScan_89\"],\"outbound_rows\":0,\"outbound_blocks\":0,\"outbound_bytes\":0,\"outbound_allocated_bytes\":0,\"execution_time_ns\":0},{\"id\":\"TableFullScan_89\",\"type\":\"TableScan\",\"children\":[],\"outbound_rows\":0,\"outbound_blocks\":0,\"outbound_bytes\":0,\"outbound_allocated_bytes\":0,\"execution_time_ns\":0,\"connection_details\":[{\"is_local\":true,\"packets\":0,\"bytes\":0},{\"is_local\":false,\"packets\":0,\"bytes\":0}]}],\"host\":\"127.0.0.1:3930\",\"task_init_timestamp\":1695035023526324000,\"task_start_timestamp\":1695035023540621000,\"task_end_timestamp\":1695035023553814000,\"compile_start_timestamp\":1695035023528147000,\"compile_end_timestamp\":1695035023540080000,\"read_wait_index_start_timestamp\":1695035023533811000,\"read_wait_index_end_timestamp\":1695035023536429000,\"local_input_bytes\":0,\"remote_input_bytes\":0,\"output_bytes\":0,\"status\":\"FAILED\",\"error_message\":\"Code: 0, e.displayText() = DB::Exception: Block column ExchangeSender_116_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0 _1 schema mismatch in FineGrainedShuffleWriter-V1: different types: expected Nullable(Decimal(8,2)), got Nullable(Decimal(30,2)), e.what() = DB::Exception,\",\"cpu_ru\":0,\"read_ru\":0,\"memory_peak\":0}"] [source="mpp_task_tracing MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.554 +08:00] [DEBUG] [MPPTask.cpp:641] ["task ends, time cost is 26 ms."] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.554 +08:00] [DEBUG] [MPPTask.cpp:359] ["task unregistered"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.554 +08:00] [INFO] [MPPTask.cpp:149] ["finish MPPTask: MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3>"] [thread_id=337]
[2023/09/18 19:03:43.556 +08:00] [DEBUG] [UnorderedInputStream.h:52] ["Destroy, pool_id=4 ref_no=0"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3> table_id=106"] [thread_id=337]
[2023/09/18 19:03:43.557 +08:00] [DEBUG] [SegmentReadTaskPool.h:198] ["Done. pool_id=4 table_id=106 pop=0 pop_empty=0 pop_empty_ratio=0 max_queue_size=0 blk_avg_bytes=0 approximate_max_pending_block_bytes=0.00MB total_count=0 total_bytes=0.00MB total_rows=0 avg_block_rows=0 avg_rows_bytes=0B"] [source="MPP<gather_id:<gather_id:1, query_ts:1695035023518509547, local_query_id:3, server_id:1074, start_ts:444343261183606785, resource_gorup: >,task_id:3> table_id=106"] [thread_id=337]

2. What did you expect to see? (Required)

success

3. What did you see instead (Required)

ERROR 1105 (HY000): other error for mpp stream: Code: 0, e.displayText() = DB::Exception: Block schema mismatch in FineGrainedShuffleWriter-V1: different types: expected Nullable(Decimal(8,2)), got Nullable(Decimal(30,2)), e.what() = DB::Exception,

4. What is your TiFlash version? (Required)

master

SeaRise commented 1 year ago
use test;
drop table if exists t1;
CREATE TABLE t1 (
  `store_no` varchar(10) NOT NULL,
  `amount` decimal(8,2) NOT NULL DEFAULT '0.00'
);
drop table if exists t2;
CREATE TABLE t2 (
  `year_month` date NOT NULL,
  `amount` decimal(8,2) NOT NULL
);
alter table t1 set tiflash replica 1;
alter table t2 set tiflash replica 1;

set tidb_allow_mpp=1;set tidb_enforce_mpp=1; set tidb_isolation_read_engines='tiflash';
SELECT SUM(col2)
FROM (
    SELECT SUM(amount) AS col1, 0.0 AS col2
    FROM t1
    GROUP BY store_no
    UNION ALL
    SELECT 0.0 AS col1, 0.0 AS col2
    FROM t2
    WHERE amount = 1
    UNION ALL
    SELECT 0.0 AS col1, amount AS col2
    FROM t2
    WHERE `year_month` = '2023-09-12 00:00:00.0'
) temp
GROUP BY col1;

+--------------------------------------------------+----------+--------------+---------------+-----------------------------------------------------------------------------------------------------------------------------+
| id                                               | estRows  | task         | access object | operator info                                                                                                               |
+--------------------------------------------------+----------+--------------+---------------+-----------------------------------------------------------------------------------------------------------------------------+
| TableReader_112                                  | 8002.00  | root         |               | MppVersion: 2, data:ExchangeSender_111                                                                                      |
| └─ExchangeSender_111                             | 8002.00  | mpp[tiflash] |               | ExchangeType: PassThrough                                                                                                   |
|   └─Projection_106                               | 8002.00  | mpp[tiflash] |               | Column#17                                                                                                                   |
|     └─HashAgg_104                                | 8002.00  | mpp[tiflash] |               | group by:Column#15, funcs:sum(Column#16)->Column#17, stream_count: 36                                                       |
|       └─ExchangeReceiver_90                      | 8020.00  | mpp[tiflash] |               | stream_count: 36                                                                                                            |
|         └─ExchangeSender_89                      | 8020.00  | mpp[tiflash] |               | ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: Column#15, collate: binary], stream_count: 36             |
|           └─Union_88                             | 8020.00  | mpp[tiflash] |               |                                                                                                                             |
|             ├─Projection_83                      | 8000.00  | mpp[tiflash] |               | Column#4->Column#15, 0.00->Column#16                                                                                        |
|             │ └─Projection_57                    | 8000.00  | mpp[tiflash] |               | Column#4                                                                                                                    |
|             │   └─HashAgg_58                     | 8000.00  | mpp[tiflash] |               | group by:test.t1.store_no, funcs:sum(Column#28)->Column#4, stream_count: 36                                                 |
|             │     └─ExchangeReceiver_60          | 8000.00  | mpp[tiflash] |               | stream_count: 36                                                                                                            |
|             │       └─ExchangeSender_59          | 8000.00  | mpp[tiflash] |               | ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t1.store_no, collate: utf8mb4_bin], stream_count: 36 |
|             │         └─HashAgg_55               | 8000.00  | mpp[tiflash] |               | group by:test.t1.store_no, funcs:sum(test.t1.amount)->Column#28                                                             |
|             │           └─TableFullScan_44       | 10000.00 | mpp[tiflash] | table:t1      | keep order:false, stats:pseudo                                                                                              |
|             ├─Projection_84                      | 10.00    | mpp[tiflash] |               | 0.00->Column#15, 0.00->Column#16                                                                                            |
|             │ └─Selection_70                     | 10.00    | mpp[tiflash] |               | eq(test.t2.amount, 1)                                                                                                       |
|             │   └─TableFullScan_69               | 10000.00 | mpp[tiflash] | table:t2      | pushed down filter:empty, keep order:false, stats:pseudo                                                                    |
|             └─Projection_113                     | 10.00    | mpp[tiflash] |               | Column#15, cast(Column#16, decimal(8,2) BINARY)->Column#16                                                                  |
|               └─Projection_85                    | 10.00    | mpp[tiflash] |               | 0.00->Column#15, test.t2.amount->Column#16                                                                                  |
|                 └─TableFullScan_79               | 10.00    | mpp[tiflash] | table:t2      | pushed down filter:eq(test.t2.year_month, 2023-09-12 00:00:00.000000), keep order:false, stats:pseudo                       |
+--------------------------------------------------+----------+--------------+---------------+-----------------------------------------------------------------------------------------------------------------------------+
SeaRise commented 1 year ago

Turning off fine grained shuffle can workaround set tiflash_fine_grained_shuffle_stream_count = -1;

SeaRise commented 1 year ago
DAGQueryBlock:
schema before analyzer.appendFinalProjectForRootQueryBlock: Decimal(2,2), Decimal(2,2)
output_offsets and require_schema in build final projection: <0, Nullable(Decimal(30,2))>, <1, Nullable(Decimal(8,2))>
schema after analyzer.appendFinalProjectForRootQueryBlock: Nullable(Decimal(30,2)), Nullable(Decimal(8,2))

Planner:
schema before analyzer.buildFinalProjection: Decimal(2,2), Decimal(2,2)
output_offsets and require_schema in build final projection: <0, Nullable(Decimal(30,2))>, <1, Nullable(Decimal(8,2))>
schema after analyzer.buildFinalProjection: Nullable(Decimal(30,2)), Nullable(Decimal(30,2))

The same build final projection is correct on the query block side, but the planner is wrong.

<ExchangeSender, ExchangeSender_89> | is_tidb_operator: true, schema: <ExchangeSender_89_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0 , Nullable(Decimal(30,2))>, <ExchangeSender_89_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0 _1, Nullable(Decimal(30,2))>
 <Projection, Projection_84> | is_tidb_operator: false, schema: <ExchangeSender_89_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0 , Nullable(Decimal(30,2))>, <ExchangeSender_89_CAST(0.00_Decimal(2,2), Nullable(Decimal(30,2))_String)_collator_0 _1, Nullable(Decimal(30,2))>
  <Projection, Projection_84> | is_tidb_operator: true, schema: <0.00_Decimal(2,2), Decimal(2,2)>, <0.00_Decimal(2,2), Decimal(2,2)>
   <TableScan, TableFullScan_69> | is_tidb_operator: true, schema: <table_scan_0, Decimal(8,2)>

The reason is that there is a column with the same name in the schema of Projection_84, which causes problems with analyzer.buildFinalProjection. https://github.com/pingcap/tiflash/blob/903525a3844c4be38fc17dcb34186557905d8d11/dbms/src/Flash/Coprocessor/DAGExpressionAnalyzer.cpp#L1514-L1515