Skip to content

Commit f6e3283

Browse files
committed
Don't make field public
Signed-off-by: Xuanwo <github@xuanwo.io>
1 parent b5c211a commit f6e3283

File tree

8 files changed

+46
-17
lines changed

8 files changed

+46
-17
lines changed

src/query/planner/src/metadata.rs

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,21 +174,21 @@ impl Metadata {
174174

175175
#[derive(Clone)]
176176
pub struct TableEntry {
177-
pub index: IndexType,
178-
pub name: String,
179-
pub catalog: String,
180-
pub database: String,
177+
catalog: String,
178+
database: String,
179+
name: String,
180+
index: IndexType,
181181

182-
pub table: Arc<dyn Table>,
182+
table: Arc<dyn Table>,
183183
}
184184

185185
impl Debug for TableEntry {
186186
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
187187
f.debug_struct("TableEntry")
188-
.field("index", &self.index)
189-
.field("name", &self.name)
190188
.field("catalog", &self.catalog)
191189
.field("database", &self.database)
190+
.field("name", &self.name)
191+
.field("index", &self.index)
192192
.finish_non_exhaustive()
193193
}
194194
}
@@ -209,6 +209,31 @@ impl TableEntry {
209209
table,
210210
}
211211
}
212+
213+
/// Get the catalog name of this table entry.
214+
pub fn catalog(&self) -> &str {
215+
&self.catalog
216+
}
217+
218+
/// Get the database name of this table entry.
219+
pub fn database(&self) -> &str {
220+
&self.database
221+
}
222+
223+
/// Get the name of this table entry.
224+
pub fn name(&self) -> &str {
225+
&self.name
226+
}
227+
228+
/// Get the index this table entry.
229+
pub fn index(&self) -> IndexType {
230+
self.index
231+
}
232+
233+
/// Get the table of this table entry.
234+
pub fn table(&self) -> Arc<dyn Table> {
235+
self.table.clone()
236+
}
212237
}
213238

214239
#[derive(Clone, Debug)]

src/query/service/src/sql/executor/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn table_scan_to_format_tree(
6969
return Ok(FormatTreeNode::new("DummyTableScan".to_string()));
7070
}
7171
let table = metadata.read().table(plan.table_index).clone();
72-
let table_name = format!("{}.{}.{}", table.catalog, table.database, table.name);
72+
let table_name = format!("{}.{}.{}", table.catalog(), table.database(), table.name());
7373
let filters = plan
7474
.source
7575
.push_downs

src/query/service/src/sql/executor/physical_plan_builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,15 @@ impl PhysicalPlanBuilder {
136136
}
137137

138138
let table_entry = metadata.table(scan.table_index);
139-
let table = table_entry.table.clone();
139+
let table = table_entry.table();
140140
let table_schema = table.schema();
141141

142142
let push_downs = self.push_downs(scan, &table_schema, has_inner_column)?;
143143

144144
let source = table
145145
.read_plan_with_catalog(
146146
self.ctx.clone(),
147-
table_entry.catalog.clone(),
147+
table_entry.catalog().to_string(),
148148
Some(push_downs),
149149
)
150150
.await?;

src/query/service/src/sql/executor/physical_scalar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl PhysicalScalar {
7272
let column = metadata.read().column(index).clone();
7373
let table_name = match column.table_index {
7474
Some(table_index) => {
75-
format!("{}.", metadata.read().table(table_index).name.clone())
75+
format!("{}.", metadata.read().table(table_index).name())
7676
}
7777
None => "".to_string(),
7878
};

src/query/service/src/sql/planner/binder/table.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ impl<'a> Binder {
294294
for column in columns.iter() {
295295
let column_binding = ColumnBinding {
296296
database_name: Some(database_name.to_string()),
297-
table_name: Some(table.name.clone()),
297+
table_name: Some(table.name().to_string()),
298298
column_name: column.name.clone(),
299299
index: column.column_index,
300300
data_type: Box::new(column.data_type.clone()),
@@ -306,7 +306,7 @@ impl<'a> Binder {
306306
};
307307
bind_context.add_column_binding(column_binding);
308308
}
309-
let stat = table.table.statistics(self.ctx.clone()).await?;
309+
let stat = table.table().statistics(self.ctx.clone()).await?;
310310
Ok((
311311
SExpr::create_leaf(
312312
LogicalGet {

src/query/service/src/sql/planner/format/display_rel_operator.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ fn physical_scan_to_format_tree(
246246
vec![
247247
FormatTreeNode::new(FormatContext::Text(format!(
248248
"table: {}.{}.{}",
249-
&table.catalog, &table.database, &table.name,
249+
table.catalog(),
250+
table.database(),
251+
table.name(),
250252
))),
251253
FormatTreeNode::new(FormatContext::Text(format!(
252254
"filters: [{}]",
@@ -302,7 +304,9 @@ fn logical_get_to_format_tree(
302304
vec![
303305
FormatTreeNode::new(FormatContext::Text(format!(
304306
"table: {}.{}.{}",
305-
&table.catalog, &table.database, &table.name,
307+
table.catalog(),
308+
table.database(),
309+
table.name(),
306310
))),
307311
FormatTreeNode::new(FormatContext::Text(format!(
308312
"filters: [{}]",

src/query/service/src/sql/planner/optimizer/heuristic/prewhere_optimization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl PrewhereOptimizer {
9595
let mut get: LogicalGet = s_expr.child(0)?.plan().clone().try_into()?;
9696
let metadata = self.metadata.read().clone();
9797

98-
let table = metadata.table(get.table_index).table.clone();
98+
let table = metadata.table(get.table_index).table();
9999
if !table.support_prewhere() {
100100
// cannot optimize
101101
return Ok(s_expr);

src/query/service/src/sql/planner/optimizer/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub fn contains_local_table_scan(s_expr: &SExpr, metadata: &MetadataRef) -> bool
2525
.iter()
2626
.any(|s_expr| contains_local_table_scan(s_expr, metadata))
2727
|| if let RelOperator::LogicalGet(get) = s_expr.plan() {
28-
metadata.read().table(get.table_index).table.is_local()
28+
metadata.read().table(get.table_index).table().is_local()
2929
} else {
3030
false
3131
}

0 commit comments

Comments
 (0)