//! Translate Hamelin IR to DataFusion LogicalPlans
//!
//! This crate provides translation from Hamelin's lowered intermediate representation (IR)
//! to DataFusion's logical plan representation, enabling direct execution of
//! Hamelin queries on DataFusion without SQL string generation.

mod codec;
mod command;
mod dataset_table_catalog;
mod exec;
#[cfg(feature = "executor")]
mod executor;
mod expr;
mod func;
#[cfg(feature = "executor")]
mod optimizer;
mod pipeline;
mod struct_expansion;
mod translate_api;
mod udf;
mod variant_walker;

pub mod arrow;
#[cfg(feature = "executor")]
mod aws;
#[cfg(feature = "executor")]
mod config;
#[cfg(feature = "executor")]
mod file_scan_common;
#[cfg(feature = "executor")]
mod iceberg;
#[cfg(feature = "executor")]
mod json;
#[cfg(feature = "executor")]
mod lines;
pub mod statement;

pub use dataset_table_catalog::DatasetTableCatalog;
#[cfg(feature = "executor")]
pub use executor::{DataFusionExecutor, DataFusionExecutorConf, DataFusionExecutorConfig};
#[cfg(feature = "executor")]
pub use iceberg::{DefaultIcebergTableResolver, IcebergTableResolver};
pub use statement::TranslatedStatement;
pub use translate_api::{
    parse_and_translate, parse_and_translate_with_options, parse_and_translate_with_time_range,
    translate_with_options, type_check_and_translate, type_check_and_translate_with_options,
};

// Public surface for embedders that build their own SessionContext (e.g. phantom):
//
// - `register_extensions` wires Hamelin's custom physical-plan extension planners
//   AND the Hamelin optimizer-rule overrides (forked
//   `extract_leaf_expressions` / `push_down_leaf_projections` plus
//   `JsonRewrite`) into a `SessionStateBuilder`. One call covers everything.
// - `HamelinPhysicalCodec` is a codec type implementing DataFusion's
//   `PhysicalExtensionCodec`. Embedders compose it into their own codec and
//   delegate; methods return `DataFusionError::NotImplemented` for non-Hamelin
//   nodes so the embedder can fall through to its own logic.
//
// We don't expose a logical codec — distributed callers lower to physical plans
// before serializing, so the logical-extension round-trip isn't on the hot path.
pub use codec::HamelinPhysicalCodec;
pub use exec::register_extensions;
