@@ -17,7 +17,9 @@ use std::sync::Arc;
17
17
use either:: Either ;
18
18
use itertools:: Itertools ;
19
19
use risingwave_common:: bail_not_implemented;
20
- use risingwave_common:: catalog:: { debug_assert_column_ids_distinct, is_system_schema, Field } ;
20
+ use risingwave_common:: catalog:: {
21
+ debug_assert_column_ids_distinct, is_system_schema, Engine , Field ,
22
+ } ;
21
23
use risingwave_common:: session_config:: USER_NAME_WILD_CARD ;
22
24
use risingwave_connector:: WithPropertiesExt ;
23
25
use risingwave_sqlparser:: ast:: { AsOf , Statement , TableAlias } ;
@@ -129,7 +131,31 @@ impl Binder {
129
131
. catalog
130
132
. get_created_table_by_name ( & self . db_name , schema_path, table_name)
131
133
{
132
- self . resolve_table_relation ( table_catalog. clone ( ) , schema_name, as_of) ?
134
+ match table_catalog. engine ( ) {
135
+ Engine :: Iceberg => {
136
+ if self . is_for_batch ( )
137
+ && let Ok ( ( source_catalog, _) ) =
138
+ self . catalog . get_source_by_name (
139
+ & self . db_name ,
140
+ schema_path,
141
+ & table_catalog. iceberg_source_name ( ) . unwrap ( ) ,
142
+ )
143
+ {
144
+ self . resolve_source_relation ( & source_catalog. clone ( ) , as_of)
145
+ } else {
146
+ self . resolve_table_relation (
147
+ table_catalog. clone ( ) ,
148
+ schema_name,
149
+ as_of,
150
+ ) ?
151
+ }
152
+ }
153
+ Engine :: Hummock => self . resolve_table_relation (
154
+ table_catalog. clone ( ) ,
155
+ schema_name,
156
+ as_of,
157
+ ) ?,
158
+ }
133
159
} else if let Ok ( ( source_catalog, _) ) =
134
160
self . catalog
135
161
. get_source_by_name ( & self . db_name , schema_path, table_name)
@@ -177,11 +203,36 @@ impl Binder {
177
203
} else if let Some ( table_catalog) =
178
204
schema. get_created_table_by_name ( table_name)
179
205
{
180
- return self . resolve_table_relation (
181
- table_catalog. clone ( ) ,
182
- & schema_name. clone ( ) ,
183
- as_of,
184
- ) ;
206
+ match table_catalog. engine {
207
+ Engine :: Iceberg => {
208
+ if self . is_for_batch ( )
209
+ && let Some ( source_catalog) = schema
210
+ . get_source_by_name (
211
+ & table_catalog
212
+ . iceberg_source_name ( )
213
+ . unwrap ( ) ,
214
+ )
215
+ {
216
+ return Ok ( self . resolve_source_relation (
217
+ & source_catalog. clone ( ) ,
218
+ as_of,
219
+ ) ) ;
220
+ } else {
221
+ return self . resolve_table_relation (
222
+ table_catalog. clone ( ) ,
223
+ & schema_name. clone ( ) ,
224
+ as_of,
225
+ ) ;
226
+ }
227
+ }
228
+ Engine :: Hummock => {
229
+ return self . resolve_table_relation (
230
+ table_catalog. clone ( ) ,
231
+ & schema_name. clone ( ) ,
232
+ as_of,
233
+ ) ;
234
+ }
235
+ }
185
236
} else if let Some ( source_catalog) =
186
237
schema. get_source_by_name ( table_name)
187
238
{
0 commit comments