Skip to content

refactor: CastExpr queries CastRulesRegistry before operator methods (#17012)#17012

Open
natashasehgal wants to merge 2 commits intofacebookincubator:mainfrom
natashasehgal:export-D99232107
Open

refactor: CastExpr queries CastRulesRegistry before operator methods (#17012)#17012
natashasehgal wants to merge 2 commits intofacebookincubator:mainfrom
natashasehgal:export-D99232107

Conversation

@natashasehgal
Copy link
Copy Markdown
Contributor

@natashasehgal natashasehgal commented Apr 2, 2026

Summary:

CastExpr::applyPeeled() now checks CastRulesRegistry::canCast() before falling back to the per-operator isSupportedFromType()/isSupportedToType() methods. This makes the registry the primary source of truth for cast validation, with operator methods as a fallback for types not yet fully migrated to the registry (e.g., JSON container types like ARRAY→JSON that require recursive type checking).

This is a no-op behavioral change: the registry answers match what operators would answer for all registered types. The fallback path ensures JSON container casts and any future types with complex validation continue to work.

Differential Revision: D99232107

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 2, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Apr 2, 2026

@natashasehgal has exported this pull request. If you are a Meta employee, you can view the originating Diff in D99232107.

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 2, 2026

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 73bbbd9
🔍 Latest deploy log https://app.netlify.com/projects/meta-velox/deploys/69cee4212bd01000089685f9

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

Build Impact Analysis

Selective Build Targets (building these covers all 495 affected)

cmake --build _build/release --target aggregate_companion_functions_test bias_vector_test cached_factory_test copy_benchmark file_utils_test physical_size_aggregator_test presto_sql_test simple_lru_cache_test simple_vector_test spark_aggregation_fuzzer_test spark_expression_fuzzer_test velox_abfs_test velox_aggregates_GeometryAggregateTest velox_aggregates_reduce_agg_bm velox_aggregates_simple_aggregates_bm velox_aggregates_string_keys_bm velox_aggregates_test_group0 velox_aggregates_test_group1 velox_aggregates_test_group2 velox_aggregates_test_group3 velox_aggregates_test_group4 velox_aggregation_fuzzer_test velox_aggregation_runner_test velox_arrow_bridge_test velox_base_test velox_benchmark_array_writer_no_nulls velox_benchmark_array_writer_with_nulls velox_benchmark_basic_comparison_conjunct velox_benchmark_basic_decoded_vector velox_benchmark_basic_preproc velox_benchmark_basic_selectivity_vector velox_benchmark_basic_simple_arithmetic velox_benchmark_basic_simple_cast velox_benchmark_basic_vector_compare velox_benchmark_basic_vector_fuzzer velox_benchmark_basic_vector_slice velox_benchmark_estimate_flat_size velox_benchmark_expr_flat_no_nulls velox_benchmark_feature_normalization velox_benchmark_map_writer_no_nulls velox_benchmark_map_writer_with_nulls velox_benchmark_nested_array_writer_no_nulls velox_benchmark_nested_array_writer_with_nulls velox_buffer_test velox_cache_fuzzer velox_cache_test_group0 velox_cast_benchmark velox_common_base_benchmarks velox_common_compression_test velox_common_encode_test velox_common_geospatial_serde_test velox_common_hyperloglog_dense_hll_bm velox_common_hyperloglog_test velox_common_indexed_priority_queue_benchmark velox_common_sorting_network_benchmark velox_common_split_block_bloom_filter_benchmark velox_common_stringsearch_benchmarks velox_common_test velox_concurrent_allocation_benchmark velox_config_test velox_connector_registry velox_connector_test velox_constrained_input_generators_test velox_constrained_vector_generator_test velox_core_plan_consistency_checker_test velox_core_test velox_demo_rpc_function_test velox_driver_test velox_duckdb_conversion_test velox_dwio_arrow_parquet_writer_test velox_dwio_cache_test velox_dwio_common_bitpack_decoder_benchmark velox_dwio_common_data_buffer_benchmark velox_dwio_common_int_decoder_benchmark velox_dwio_common_test velox_dwio_dwrf_buffered_output_stream_test velox_dwio_dwrf_byte_rle_encoder_test velox_dwio_dwrf_byte_rle_test velox_dwio_dwrf_checksum_test velox_dwio_dwrf_column_reader_test velox_dwio_dwrf_column_statistics_test velox_dwio_dwrf_compression_test velox_dwio_dwrf_config_test velox_dwio_dwrf_data_buffer_holder_test velox_dwio_dwrf_decompression_test velox_dwio_dwrf_decryption_test velox_dwio_dwrf_dictionary_encoder_test velox_dwio_dwrf_dictionary_encoding_utils_test velox_dwio_dwrf_encoding_selector_test velox_dwio_dwrf_encryption_test velox_dwio_dwrf_flush_policy_test velox_dwio_dwrf_index_builder_test velox_dwio_dwrf_int_direct_test velox_dwio_dwrf_int_encoder_test velox_dwio_dwrf_layout_planner_test velox_dwio_dwrf_ratio_checker_test velox_dwio_dwrf_reader_base_test velox_dwio_dwrf_reader_test velox_dwio_dwrf_rle_test velox_dwio_dwrf_rlev1_encoder_test velox_dwio_dwrf_stream_labels_test velox_dwio_dwrf_stripe_dictionary_cache_test velox_dwio_dwrf_stripe_reader_base_test velox_dwio_dwrf_stripe_stream_test velox_dwio_dwrf_utils_test velox_dwio_dwrf_writer_context_test velox_dwio_dwrf_writer_encoding_manager_test velox_dwio_dwrf_writer_sink_test velox_dwio_dwrf_writer_test velox_dwio_iceberg_reader_benchmark velox_dwio_orc_column_statistics_test velox_dwio_orc_reader_filter_test velox_dwio_orc_reader_test velox_dwio_parquet_common_test velox_dwio_parquet_page_reader_test velox_dwio_parquet_reader_benchmark velox_dwio_parquet_reader_test velox_dwio_parquet_rlebp_decoder_test velox_dwio_parquet_structure_decoder_benchmark velox_dwio_parquet_structure_decoder_test velox_dwio_parquet_table_scan_test velox_dwio_parquet_thrift_test velox_dwio_parquet_tpch_test velox_dwrf_column_writer_index_test velox_dwrf_column_writer_stats_test velox_dwrf_column_writer_test velox_dwrf_e2e_filter_test velox_dwrf_e2e_reader_test velox_dwrf_e2e_writer_test velox_dwrf_float_column_writer_benchmark velox_dwrf_int_encoder_benchmark velox_dwrf_statistics_builder_utils_test velox_dwrf_writer_extended_test velox_dwrf_writer_flush_test velox_example_expression_eval velox_example_opaque_type velox_example_operator_extensibility velox_example_scan_orc velox_example_simple_functions velox_example_vector_reader_writer velox_exchange_benchmark velox_exchange_fuzzer velox_exec_SpatialJoinTest velox_exec_bm_duplicate_project velox_exec_infra_test velox_exec_prefixsort_test velox_exec_test_group0 velox_exec_test_group1 velox_exec_test_group2 velox_exec_test_group3 velox_exec_test_group4 velox_exec_test_group5 velox_exec_test_group6 velox_exec_test_group7 velox_exec_util_test_group0 velox_exec_vector_hasher_benchmark velox_expression_fuzzer_test velox_expression_fuzzer_unit_test velox_expression_runner_test velox_expression_runner_unit_test velox_expression_test velox_expression_verifier_unit_test velox_file_test velox_filemetadata_test velox_filter_benchmark velox_filter_project_benchmark velox_format_datetime_benchmark velox_fragmentation_benchmark velox_function_dynamic_link_test velox_function_registry_test velox_functions_aggregates_test velox_functions_benchmarks_compare velox_functions_benchmarks_row_writer_no_nulls velox_functions_benchmarks_simdjson_function_with_expr velox_functions_benchmarks_string_writer_no_nulls velox_functions_benchmarks_url velox_functions_iceberg_test velox_functions_json_test velox_functions_lib_test velox_functions_prestosql_benchmarks_array_contains velox_functions_prestosql_benchmarks_array_min_max velox_functions_prestosql_benchmarks_array_position velox_functions_prestosql_benchmarks_array_sum velox_functions_prestosql_benchmarks_bitwise velox_functions_prestosql_benchmarks_cardinality velox_functions_prestosql_benchmarks_comparisons velox_functions_prestosql_benchmarks_concat velox_functions_prestosql_benchmarks_date_time velox_functions_prestosql_benchmarks_field_reference velox_functions_prestosql_benchmarks_generic velox_functions_prestosql_benchmarks_in velox_functions_prestosql_benchmarks_map_input velox_functions_prestosql_benchmarks_map_subscript velox_functions_prestosql_benchmarks_map_zip_with velox_functions_prestosql_benchmarks_not velox_functions_prestosql_benchmarks_regexp_replace velox_functions_prestosql_benchmarks_row velox_functions_prestosql_benchmarks_string_ascii_utf_functions velox_functions_prestosql_benchmarks_uuid_cast velox_functions_prestosql_benchmarks_width_bucket velox_functions_prestosql_benchmarks_zip velox_functions_prestosql_benchmarks_zip_with velox_functions_sfm_test velox_functions_spark_aggregates_test velox_functions_spark_test velox_functions_string_test velox_functions_test velox_fuzzer_connector_test velox_gcs_file_test velox_gcs_insert_test velox_gcs_multiendpoints_test velox_gcsfile_example velox_hash_benchmark velox_hash_join_build_benchmark velox_hash_join_list_result_benchmark velox_hash_join_prepare_join_table_benchmark velox_hdfs_file_test velox_hdfs_insert_test velox_hierarchical_timer_test velox_hive_connector_test velox_hive_iceberg_insert_test velox_hive_iceberg_test velox_hive_paimon_connector velox_hive_paimon_data_file_meta_test velox_hive_paimon_deletion_file_test velox_hive_paimon_row_kind_test velox_hive_paimon_split_test velox_hive_partition_function_benchmark velox_id_map_test velox_in_10_min_demo velox_join_fuzzer velox_key_encoder_test velox_like_benchmark velox_like_tpch_benchmark velox_mark_distinct_fuzzer velox_mark_sorted_benchmark velox_memcpy_meter velox_memory_arbitration_fuzzer velox_memory_test velox_merge_benchmark velox_mock_rpc_client_test velox_negated_bigint_range_benchmark velox_negated_bytes_range_benchmark velox_negated_bytes_values_benchmark velox_negated_values_filter_benchmark velox_orderby_benchmark velox_parquet_e2e_filter_test velox_parquet_writer_sink_test velox_parquet_writer_test velox_parse_test velox_prefix_sort_algorithm_benchmark velox_prefixsort_benchmark velox_presto_type_parser_test velox_presto_types_fuzzer_utils_test velox_presto_types_test velox_prestosql_coverage velox_process_test velox_query_replayer velox_re2_functions_benchmarks velox_read_benchmark velox_row_number_fuzzer velox_row_serializer_benchmark velox_row_test velox_rpc_node_test velox_rpc_operator_test velox_rpc_state_test velox_s3config_test velox_s3file_test velox_s3finalize_test velox_s3insert_test velox_s3metrics_test velox_s3multiendpoints_test velox_s3read_test velox_s3registration_test velox_serialization_test velox_serializer_benchmark velox_serializer_test_group0 velox_signature_parser_test velox_simple_aggregate_test velox_sort_benchmark velox_spark_function_registry_test velox_spark_query_runner_test velox_spark_types_test velox_spark_windows_test velox_sparksql_benchmarks_cast velox_sparksql_benchmarks_compare velox_sparksql_benchmarks_from_json velox_sparksql_benchmarks_get_funcs velox_sparksql_benchmarks_hash velox_sparksql_benchmarks_in velox_sparksql_benchmarks_simd_compare velox_sparksql_benchmarks_split velox_sparksql_coverage velox_spatial_join_benchmark velox_spatial_join_fuzzer velox_spiller_aggregate_benchmark velox_spiller_join_benchmark velox_streaming_aggregation_benchmark velox_string_core_benchmark velox_string_view_benchmark velox_table_evolution_fuzzer_test velox_test_util_test velox_text_reader_test velox_text_writer_test velox_time_test velox_tool_trace_test velox_topn_row_number_fuzzer velox_tpcds_connector_test velox_tpcds_gen_test velox_tpch_benchmark velox_tpch_connector_test velox_tpch_gen_test velox_tpch_speed_test velox_trace_file_tool velox_type_fbhive_test velox_type_serializer_fbhive_test velox_type_test velox_type_tz_ext_invalid_test velox_type_tz_test velox_unsafe_row_serialize_benchmark velox_vector_fuzzer_test velox_vector_hash_all_benchmark velox_vector_map_update_benchmark velox_vector_selectivity_vector_benchmark velox_vector_test velox_wave_benchmark velox_wave_common_test velox_wave_decode_test velox_wave_exec_test velox_window_fuzzer_test velox_window_prefixsort_benchmark velox_window_sub_partitioned_sort_benchmark velox_windows_agg_test velox_windows_rank_test velox_windows_value_test velox_writer_fuzzer_test

Total affected: 495/556 targets

Affected targets (495)

Directly changed (12)

Target Changed Files
velox_expression CastExpr.cpp, CastExpr.h
velox_expression_test CastExpr.h
velox_functions_prestosql CastExpr.h
velox_functions_prestosql_impl CastExpr.h
velox_functions_spark CastExpr.h
velox_functions_spark_specialforms CastExpr.h
velox_functions_test CastExpr.h
velox_presto_types BigintEnumRegistration.cpp, BingTileRegistration.cpp, CastExpr.h, IPAddressRegistration.cpp, IPPrefixRegistration.cpp, ... (+4 more)
velox_presto_types_test CastExpr.h, IPPrefixTypeTest.cpp
velox_spark_function_registry_test CastExpr.h
velox_spark_types CastExpr.h, TimestampNTZRegistration.cpp
velox_type CastRegistry.cpp, TypeCoercer.cpp

Transitively affected (483)

  • aggregate_companion_functions_test
  • bias_vector_test
  • cached_factory_test
  • copy_benchmark
  • file_utils_test
  • physical_size_aggregator_test
  • presto_sql_test
  • simple_lru_cache_test
  • simple_vector_test
  • spark_aggregation_fuzzer_test
  • spark_expression_fuzzer_test
  • velox_abfs
  • velox_abfs_test
  • velox_aggregates
  • velox_aggregates_GeometryAggregateTest
  • velox_aggregates_reduce_agg_bm
  • velox_aggregates_simple_aggregates_bm
  • velox_aggregates_string_keys_bm
  • velox_aggregates_test_group0
  • velox_aggregates_test_group1
  • velox_aggregates_test_group2
  • velox_aggregates_test_group3
  • velox_aggregates_test_group4
  • velox_aggregation_fuzzer
  • velox_aggregation_fuzzer_base
  • velox_aggregation_fuzzer_test
  • velox_aggregation_result_verifier
  • velox_aggregation_runner_test
  • velox_arrow_bridge
  • velox_arrow_bridge_test
  • velox_async_rpc_function_registry
  • velox_base_test
  • velox_benchmark_array_writer_no_nulls
  • velox_benchmark_array_writer_with_nulls
  • velox_benchmark_basic_comparison_conjunct
  • velox_benchmark_basic_decoded_vector
  • velox_benchmark_basic_preproc
  • velox_benchmark_basic_selectivity_vector
  • velox_benchmark_basic_simple_arithmetic
  • velox_benchmark_basic_simple_cast
  • velox_benchmark_basic_vector_compare
  • velox_benchmark_basic_vector_fuzzer
  • velox_benchmark_basic_vector_slice
  • velox_benchmark_builder
  • velox_benchmark_estimate_flat_size
  • velox_benchmark_expr_flat_no_nulls
  • velox_benchmark_feature_normalization
  • velox_benchmark_map_writer_no_nulls
  • velox_benchmark_map_writer_with_nulls
  • velox_benchmark_nested_array_writer_no_nulls
  • velox_benchmark_nested_array_writer_with_nulls
  • velox_buffer
  • velox_buffer_test
  • velox_cache_fuzzer
  • velox_cache_fuzzer_lib
  • velox_cache_test_group0
  • velox_caching
  • velox_cast_benchmark
  • velox_common_base
  • velox_common_base_benchmarks
  • velox_common_compression
  • velox_common_compression_test
  • velox_common_config
  • velox_common_encode_test
  • velox_common_fuzzer_util
  • velox_common_geospatial_serde
  • velox_common_geospatial_serde_test
  • velox_common_hyperloglog
  • velox_common_hyperloglog_dense_hll_bm
  • velox_common_hyperloglog_test
  • velox_common_indexed_priority_queue_benchmark
  • velox_common_sorting_network_benchmark
  • velox_common_split_block_bloom_filter_benchmark
  • velox_common_stringsearch_benchmarks
  • velox_common_test
  • velox_concurrent_allocation_benchmark
  • velox_config_test
  • velox_connector
  • velox_connector_registry
  • velox_connector_test
  • velox_constrained_input_generators
  • velox_constrained_input_generators_test
  • velox_constrained_vector_generator
  • velox_constrained_vector_generator_test
  • velox_core
  • velox_core_plan_consistency_checker_test
  • velox_core_test
  • velox_coverage_util
  • velox_cursor
  • velox_demo_rpc_function
  • velox_demo_rpc_function_test
  • velox_driver_test
  • velox_duckdb_conversion
  • velox_duckdb_conversion_test
  • velox_duckdb_parser
  • velox_dwio_arrow_parquet_writer
  • velox_dwio_arrow_parquet_writer_lib
  • velox_dwio_arrow_parquet_writer_test
  • velox_dwio_arrow_parquet_writer_test_lib
  • velox_dwio_arrow_parquet_writer_util_lib
  • velox_dwio_cache_test
  • velox_dwio_catalog_fbhive
  • velox_dwio_common
  • velox_dwio_common_bitpack_decoder_benchmark
  • velox_dwio_common_compression
  • velox_dwio_common_data_buffer_benchmark
  • velox_dwio_common_exception
  • velox_dwio_common_int_decoder_benchmark
  • velox_dwio_common_test
  • velox_dwio_common_test_utils
  • velox_dwio_dwrf_buffered_output_stream_test
  • velox_dwio_dwrf_byte_rle_encoder_test
  • velox_dwio_dwrf_byte_rle_test
  • velox_dwio_dwrf_checksum_test
  • velox_dwio_dwrf_column_reader_test
  • velox_dwio_dwrf_column_statistics_test
  • velox_dwio_dwrf_common
  • velox_dwio_dwrf_compression_test
  • velox_dwio_dwrf_config_test
  • velox_dwio_dwrf_data_buffer_holder_test
  • velox_dwio_dwrf_decompression_test
  • velox_dwio_dwrf_decryption_test
  • velox_dwio_dwrf_dictionary_encoder_test
  • velox_dwio_dwrf_dictionary_encoding_utils_test
  • velox_dwio_dwrf_encoding_selector_test
  • velox_dwio_dwrf_encryption_test
  • velox_dwio_dwrf_flush_policy_test
  • velox_dwio_dwrf_index_builder_test
  • velox_dwio_dwrf_int_direct_test
  • velox_dwio_dwrf_int_encoder_test
  • velox_dwio_dwrf_layout_planner_test
  • velox_dwio_dwrf_ratio_checker_test
  • velox_dwio_dwrf_reader
  • velox_dwio_dwrf_reader_base_test
  • velox_dwio_dwrf_reader_test
  • velox_dwio_dwrf_rle_test
  • velox_dwio_dwrf_rlev1_encoder_test
  • velox_dwio_dwrf_stream_labels_test
  • velox_dwio_dwrf_stripe_dictionary_cache_test
  • velox_dwio_dwrf_stripe_reader_base_test
  • velox_dwio_dwrf_stripe_stream_test
  • velox_dwio_dwrf_utils
  • velox_dwio_dwrf_utils_test
  • velox_dwio_dwrf_writer
  • velox_dwio_dwrf_writer_context_test
  • velox_dwio_dwrf_writer_encoding_manager_test
  • velox_dwio_dwrf_writer_sink_test
  • velox_dwio_dwrf_writer_test
  • velox_dwio_faulty_file_sink
  • velox_dwio_iceberg_reader_benchmark
  • velox_dwio_iceberg_reader_benchmark_lib
  • velox_dwio_native_parquet_reader
  • velox_dwio_orc_column_statistics_test
  • velox_dwio_orc_reader
  • velox_dwio_orc_reader_filter_test
  • velox_dwio_orc_reader_test
  • velox_dwio_parquet_common
  • velox_dwio_parquet_common_test
  • velox_dwio_parquet_page_reader_test
  • velox_dwio_parquet_reader
  • velox_dwio_parquet_reader_benchmark
  • velox_dwio_parquet_reader_benchmark_lib
  • velox_dwio_parquet_reader_test
  • velox_dwio_parquet_rlebp_decoder_test
  • velox_dwio_parquet_structure_decoder_benchmark
  • velox_dwio_parquet_structure_decoder_test
  • velox_dwio_parquet_table_scan_test
  • velox_dwio_parquet_thrift_test
  • velox_dwio_parquet_tpch_test
  • velox_dwio_parquet_writer
  • velox_dwio_text_reader
  • velox_dwio_text_reader_register
  • velox_dwio_text_writer
  • velox_dwio_text_writer_register
  • velox_dwrf_column_writer_index_test
  • velox_dwrf_column_writer_stats_test
  • velox_dwrf_column_writer_test
  • velox_dwrf_e2e_filter_test
  • velox_dwrf_e2e_reader_test
  • velox_dwrf_e2e_writer_test
  • velox_dwrf_float_column_writer_benchmark
  • velox_dwrf_int_encoder_benchmark
  • velox_dwrf_statistics_builder_utils_test
  • velox_dwrf_test_utils
  • velox_dwrf_writer_extended_test
  • velox_dwrf_writer_flush_test
  • velox_dynamic_library_loader
  • velox_example_expression_eval
  • velox_example_opaque_type
  • velox_example_operator_extensibility
  • velox_example_scan_orc
  • velox_example_simple_functions
  • velox_example_vector_reader_writer
  • velox_exception
  • velox_exchange_benchmark
  • velox_exchange_fuzzer
  • velox_exec
  • velox_exec_SpatialJoinTest
  • velox_exec_bm_duplicate_project
  • velox_exec_infra_test
  • velox_exec_prefixsort_test
  • velox_exec_prefixsort_test_lib
  • velox_exec_test_group0
  • velox_exec_test_group1
  • velox_exec_test_group2
  • velox_exec_test_group3
  • velox_exec_test_group4
  • velox_exec_test_group5
  • velox_exec_test_group6
  • velox_exec_test_group7
  • velox_exec_test_lib
  • velox_exec_util_test_group0
  • velox_exec_vector_hasher_benchmark
  • velox_expression_functions
  • velox_expression_fuzzer
  • velox_expression_fuzzer_test
  • velox_expression_fuzzer_test_utility
  • velox_expression_fuzzer_unit_test
  • velox_expression_runner
  • velox_expression_runner_test
  • velox_expression_runner_unit_test
  • velox_expression_test_utility
  • velox_expression_verifier
  • velox_expression_verifier_unit_test
  • velox_file
  • velox_file_test
  • velox_file_test_utils
  • velox_filemetadata_test
  • velox_filter_benchmark
  • velox_filter_project_benchmark
  • velox_format_datetime_benchmark
  • velox_fragmentation_benchmark
  • velox_function_dynamic_link_test
  • velox_function_registry
  • velox_function_registry_test
  • velox_functions_aggregates
  • velox_functions_aggregates_test
  • velox_functions_aggregates_test_lib
  • velox_functions_benchmarks_compare
  • velox_functions_benchmarks_row_writer_no_nulls
  • velox_functions_benchmarks_simdjson_function_with_expr
  • velox_functions_benchmarks_string_writer_no_nulls
  • velox_functions_benchmarks_url
  • velox_functions_geo
  • velox_functions_iceberg
  • velox_functions_iceberg_hash
  • velox_functions_iceberg_test
  • velox_functions_json
  • velox_functions_json_test
  • velox_functions_lib
  • velox_functions_lib_date_time_formatter
  • velox_functions_lib_test
  • velox_functions_prestosql_benchmarks_array_contains
  • velox_functions_prestosql_benchmarks_array_min_max
  • velox_functions_prestosql_benchmarks_array_position
  • velox_functions_prestosql_benchmarks_array_sum
  • velox_functions_prestosql_benchmarks_bitwise
  • velox_functions_prestosql_benchmarks_cardinality
  • velox_functions_prestosql_benchmarks_comparisons
  • velox_functions_prestosql_benchmarks_concat
  • velox_functions_prestosql_benchmarks_date_time
  • velox_functions_prestosql_benchmarks_field_reference
  • velox_functions_prestosql_benchmarks_generic
  • velox_functions_prestosql_benchmarks_in
  • velox_functions_prestosql_benchmarks_map_input
  • velox_functions_prestosql_benchmarks_map_subscript
  • velox_functions_prestosql_benchmarks_map_zip_with
  • velox_functions_prestosql_benchmarks_not
  • velox_functions_prestosql_benchmarks_regexp_replace
  • velox_functions_prestosql_benchmarks_row
  • velox_functions_prestosql_benchmarks_string_ascii_utf_functions
  • velox_functions_prestosql_benchmarks_uuid_cast
  • velox_functions_prestosql_benchmarks_width_bucket
  • velox_functions_prestosql_benchmarks_zip
  • velox_functions_prestosql_benchmarks_zip_with
  • velox_functions_sfm
  • velox_functions_sfm_test
  • velox_functions_spark_aggregates
  • velox_functions_spark_aggregates_test
  • velox_functions_spark_impl
  • velox_functions_spark_test
  • velox_functions_spark_window
  • velox_functions_string_test
  • velox_functions_test_lib
  • velox_functions_util
  • velox_functions_window
  • velox_functions_window_test_lib
  • velox_fuzzer_connector
  • velox_fuzzer_connector_test
  • velox_fuzzer_util
  • velox_gcs
  • velox_gcs_file_test
  • velox_gcs_insert_test
  • velox_gcs_multiendpoints_test
  • velox_gcsfile_example
  • velox_hash_benchmark
  • velox_hash_join_build_benchmark
  • velox_hash_join_list_result_benchmark
  • velox_hash_join_prepare_join_table_benchmark
  • velox_hdfs
  • velox_hdfs_file_test
  • velox_hdfs_insert_test
  • velox_hierarchical_timer
  • velox_hierarchical_timer_test
  • velox_hive_config
  • velox_hive_connector
  • velox_hive_connector_test
  • velox_hive_iceberg_insert_test
  • velox_hive_iceberg_splitreader
  • velox_hive_iceberg_test
  • velox_hive_paimon_connector
  • velox_hive_paimon_data_file_meta_test
  • velox_hive_paimon_deletion_file_test
  • velox_hive_paimon_row_kind_test
  • velox_hive_paimon_split
  • velox_hive_paimon_split_test
  • velox_hive_partition_function
  • velox_hive_partition_function_benchmark
  • velox_id_map
  • velox_id_map_test
  • velox_in_10_min_demo
  • velox_is_null_functions
  • velox_join_fuzzer
  • velox_key_encoder
  • velox_key_encoder_test
  • velox_like_benchmark
  • velox_like_tpch_benchmark
  • velox_mark_distinct_fuzzer
  • velox_mark_distinct_fuzzer_lib
  • velox_mark_sorted_benchmark
  • velox_memcpy_meter
  • velox_memory
  • velox_memory_arbitration_fuzzer
  • velox_memory_test
  • velox_merge_benchmark
  • velox_mock_rpc_client
  • velox_mock_rpc_client_test
  • velox_negated_bigint_range_benchmark
  • velox_negated_bytes_range_benchmark
  • velox_negated_bytes_values_benchmark
  • velox_negated_values_filter_benchmark
  • velox_orderby_benchmark
  • velox_orderby_benchmark_util
  • velox_parquet_e2e_filter_test
  • velox_parquet_writer_sink_test
  • velox_parquet_writer_test
  • velox_parse_expression
  • velox_parse_parser
  • velox_parse_test
  • velox_parse_utils
  • velox_prefix_sort_algorithm_benchmark
  • velox_prefixsort_benchmark
  • velox_presto_serializer
  • velox_presto_type_parser
  • velox_presto_type_parser_test
  • velox_presto_types_fuzzer_utils
  • velox_presto_types_fuzzer_utils_test
  • velox_prestosql_coverage
  • velox_process
  • velox_process_test
  • velox_query_benchmark
  • velox_query_replayer
  • velox_query_trace_replayer_base
  • velox_re2_functions_benchmarks
  • velox_read_benchmark
  • velox_read_benchmark_lib
  • velox_row_fast
  • velox_row_number_fuzzer
  • velox_row_number_fuzzer_lib
  • velox_row_serializer_benchmark
  • velox_row_test
  • velox_rpc_function_stubs
  • velox_rpc_node_test
  • velox_rpc_operator
  • velox_rpc_operator_test
  • velox_rpc_plan_node_translator
  • velox_rpc_state
  • velox_rpc_state_test
  • velox_s3config_test
  • velox_s3file_test
  • velox_s3finalize_test
  • velox_s3fs
  • velox_s3insert_test
  • velox_s3metrics_test
  • velox_s3multiendpoints_test
  • velox_s3read_test
  • velox_s3registration_test
  • velox_serialization
  • velox_serialization_test
  • velox_serializer_benchmark
  • velox_serializer_test_group0
  • velox_signature_parser
  • velox_signature_parser_test
  • velox_simple_aggregate
  • velox_simple_aggregate_test
  • velox_sort_benchmark
  • velox_spark_query_runner
  • velox_spark_query_runner_test
  • velox_spark_types_test
  • velox_spark_windows_test
  • velox_sparksql_benchmarks_cast
  • velox_sparksql_benchmarks_compare
  • velox_sparksql_benchmarks_from_json
  • velox_sparksql_benchmarks_get_funcs
  • velox_sparksql_benchmarks_hash
  • velox_sparksql_benchmarks_in
  • velox_sparksql_benchmarks_simd_compare
  • velox_sparksql_benchmarks_split
  • velox_sparksql_coverage
  • velox_spatial_join_benchmark
  • velox_spatial_join_fuzzer
  • velox_spill_fuzzer_base_lib
  • velox_spiller_aggregate_benchmark
  • velox_spiller_aggregate_benchmark_base
  • velox_spiller_join_benchmark
  • velox_spiller_join_benchmark_base
  • velox_streaming_aggregation_benchmark
  • velox_string_core_benchmark
  • velox_string_view_benchmark
  • velox_table_evolution_fuzzer_test
  • velox_test_util
  • velox_test_util_test
  • velox_text_reader_test
  • velox_text_writer_test
  • velox_time
  • velox_time_test
  • velox_tool_trace_test
  • velox_topn_row_number_fuzzer
  • velox_topn_row_number_fuzzer_lib
  • velox_tpcds_append_info
  • velox_tpcds_connector
  • velox_tpcds_connector_test
  • velox_tpcds_dsdgen
  • velox_tpcds_gen
  • velox_tpcds_gen_test
  • velox_tpch_benchmark
  • velox_tpch_benchmark_lib
  • velox_tpch_connector
  • velox_tpch_connector_test
  • velox_tpch_gen
  • velox_tpch_gen_test
  • velox_tpch_speed_test
  • velox_trace
  • velox_trace_file_tool
  • velox_trace_file_tool_base
  • velox_type_calculation
  • velox_type_fbhive
  • velox_type_fbhive_test
  • velox_type_serializer_fbhive_test
  • velox_type_signature
  • velox_type_test
  • velox_type_tz_ext_invalid_test
  • velox_type_tz_test
  • velox_unsafe_row_serialize_benchmark
  • velox_vector
  • velox_vector_fuzzer
  • velox_vector_fuzzer_test
  • velox_vector_fuzzer_util
  • velox_vector_hash_all_benchmark
  • velox_vector_map_update_benchmark
  • velox_vector_selectivity_vector_benchmark
  • velox_vector_test
  • velox_vector_test_lib
  • velox_wave_benchmark
  • velox_wave_common
  • velox_wave_common_test
  • velox_wave_decode
  • velox_wave_decode_test
  • velox_wave_exec
  • velox_wave_exec_test
  • velox_wave_mock_file
  • velox_wave_mock_reader
  • velox_wave_vector
  • velox_window
  • velox_window_fuzzer
  • velox_window_fuzzer_test
  • velox_window_prefixsort_benchmark
  • velox_window_sub_partitioned_sort_benchmark
  • velox_windows_agg_test
  • velox_windows_rank_test
  • velox_windows_value_test
  • velox_writer_fuzzer
  • velox_writer_fuzzer_test

Fast path • Graph from main@cf7d5a7b77016a3efc796f6c30cd5538ce7b91b6

… resolution (facebookincubator#17006)

Summary:

Registers `registerCastRules()` for all remaining Presto and SparkSQL custom types that have CastOperators, declaring their supported casts in the centralized CastRulesRegistry alongside `registerCustomType()`.

Types registered (all explicit-only, no implicit coercions):
- UUID: VARCHAR, VARBINARY ↔ UUID
- BINGTILE: BIGINT ↔ BINGTILE
- IPADDRESS: VARCHAR, VARBINARY, IPPREFIX ↔ IPADDRESS
- IPPREFIX: VARCHAR, IPADDRESS ↔ IPPREFIX
- BIGINT_ENUM: TINYINT/SMALLINT/INTEGER/BIGINT → BIGINT_ENUM, BIGINT_ENUM → BIGINT
- VARCHAR_ENUM: VARCHAR ↔ VARCHAR_ENUM
- P4HYPERLOGLOG: HYPERLOGLOG ↔ P4HYPERLOGLOG
- JSON: primitive types only → JSON and JSON → primitives (container types handled by JsonCastOperator). JSON → TIMESTAMP is not supported in Presto.
- TIMESTAMP_NTZ (SparkSQL): VARCHAR → TIMESTAMP_NTZ

Also fixes a limitation in `CastRulesRegistry::castCostImpl` where the `size() == 0` guard prevented rule lookup for custom types that extend RowType. Specifically, IPPREFIX is implemented as `RowType(HUGEINT, TINYINT)` so `size() > 0`, which caused rule lookup to skip directly to the container recursion path — which then failed because the base type names differ (e.g., "VARCHAR" != "IPPREFIX"). Before this fix, `canCast(VARCHAR(), IPPREFIX())` returned false despite having a registered rule. The fix tries rule lookup by name first for all types, then falls through to container recursion only when no explicit rule exists. This is safe because container types (ARRAY, MAP, ROW) never have registered cast rules.

Differential Revision: D99173066
…acebookincubator#17012)

Summary:

CastExpr::applyPeeled() now checks CastRulesRegistry::canCast() before falling back to the per-operator isSupportedFromType()/isSupportedToType() methods. This makes the registry the primary source of truth for cast validation, with operator methods as a fallback for types not yet fully migrated to the registry (e.g., JSON container types like ARRAY<X>→JSON that require recursive type checking).

This is a no-op behavioral change: the registry answers match what operators would answer for all registered types. The fallback path ensures JSON container casts and any future types with complex validation continue to work.

Differential Revision: D99232107
@meta-codesync meta-codesync bot changed the title refactor: CastExpr queries CastRulesRegistry before operator methods refactor: CastExpr queries CastRulesRegistry before operator methods (#17012) Apr 2, 2026
natashasehgal added a commit to natashasehgal/velox that referenced this pull request Apr 2, 2026
…acebookincubator#17012)

Summary:

CastExpr::applyPeeled() now checks CastRulesRegistry::canCast() before falling back to the per-operator isSupportedFromType()/isSupportedToType() methods. This makes the registry the primary source of truth for cast validation, with operator methods as a fallback for types not yet fully migrated to the registry (e.g., JSON container types like ARRAY<X>→JSON that require recursive type checking).

This is a no-op behavioral change: the registry answers match what operators would answer for all registered types. The fallback path ensures JSON container casts and any future types with complex validation continue to work.

Differential Revision: D99232107
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant