Skip to content

Commit

Permalink
fix(iceberg): only convert iceberg table to iceberg source for batch …
Browse files Browse the repository at this point in the history
…dql (#20045)
  • Loading branch information
chenzl25 authored Jan 7, 2025
1 parent 2497760 commit ec36f40
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/frontend/src/handler/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,11 @@ fn gen_batch_query_plan(
..
} = bind_result;

let mut planner = Planner::new_for_batch(context);
let mut planner = if matches!(bound, BoundStatement::Query(_)) {
Planner::new_for_batch_dql(context)
} else {
Planner::new_for_batch(context)
};

let mut logical = planner.plan(bound)?;
let schema = logical.schema();
Expand Down
11 changes: 11 additions & 0 deletions src/frontend/src/planner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,20 @@ pub struct Planner {
pub enum PlanFor {
Stream,
Batch,
/// `BatchDql` is a special mode for batch.
/// Iceberg engine table will be converted to iceberg source based on this mode.
BatchDql,
}

impl Planner {
pub fn new_for_batch_dql(ctx: OptimizerContextRef) -> Planner {
Planner {
ctx,
share_cache: Default::default(),
plan_for: PlanFor::BatchDql,
}
}

pub fn new_for_batch(ctx: OptimizerContextRef) -> Planner {
Planner {
ctx,
Expand Down
8 changes: 5 additions & 3 deletions src/frontend/src/planner/relation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ impl Planner {
);

match (base_table.table_catalog.engine, self.plan_for()) {
(Engine::Hummock, PlanFor::Stream) | (Engine::Hummock, PlanFor::Batch) => {
(Engine::Hummock, PlanFor::Stream)
| (Engine::Hummock, PlanFor::Batch)
| (Engine::Hummock, PlanFor::BatchDql) => {
match as_of {
None
| Some(AsOf::ProcessTime)
Expand All @@ -105,7 +107,7 @@ impl Planner {
};
Ok(scan.into())
}
(Engine::Iceberg, PlanFor::Stream) => {
(Engine::Iceberg, PlanFor::Stream) | (Engine::Iceberg, PlanFor::Batch) => {
match as_of {
None
| Some(AsOf::VersionNum(_))
Expand All @@ -120,7 +122,7 @@ impl Planner {
}
Ok(scan.into())
}
(Engine::Iceberg, PlanFor::Batch) => {
(Engine::Iceberg, PlanFor::BatchDql) => {
match as_of {
None
| Some(AsOf::VersionNum(_))
Expand Down

0 comments on commit ec36f40

Please sign in to comment.