Skip to content

Commit 4f6835d

Browse files
authored
chore: add setting for table ref (#19234)
* add setting for table ref * fix
1 parent f885633 commit 4f6835d

File tree

9 files changed

+42
-3
lines changed

9 files changed

+42
-3
lines changed

src/query/ee/src/table_ref/handler.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ impl TableRefHandler for RealTableRefHandler {
4040
ctx: Arc<dyn TableContext>,
4141
plan: &CreateTableRefPlan,
4242
) -> Result<()> {
43+
if !ctx
44+
.get_settings()
45+
.get_enable_experimental_table_ref()
46+
.unwrap_or_default()
47+
{
48+
return Err(ErrorCode::Unimplemented(
49+
"Table ref is an experimental feature, `set enable_experimental_table_ref=1` to use this feature",
50+
));
51+
}
52+
4353
let tenant = ctx.get_tenant();
4454
let catalog = ctx.get_catalog(&plan.catalog).await?;
4555

src/query/service/src/sessions/query_ctx.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,15 @@ impl QueryContext {
538538
};
539539

540540
let table = if let Some(branch) = branch {
541+
if !self
542+
.get_settings()
543+
.get_enable_experimental_table_ref()
544+
.unwrap_or_default()
545+
{
546+
return Err(ErrorCode::Unimplemented(
547+
"Table ref is an experimental feature, `set enable_experimental_table_ref=1` to use this feature",
548+
));
549+
}
541550
table.with_branch(branch)?
542551
} else {
543552
table

src/query/settings/src/settings_default.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,13 @@ impl DefaultSettings {
15071507
scope: SettingScope::Both,
15081508
range: Some(SettingRange::Numeric(0..=16)),
15091509
}),
1510+
("enable_experimental_table_ref", DefaultSettingValue {
1511+
value: UserSettingValue::UInt64(0),
1512+
desc: "experiment setting enable table ref(disable by default).",
1513+
mode: SettingMode::Both,
1514+
scope: SettingScope::Both,
1515+
range: Some(SettingRange::Numeric(0..=1)),
1516+
}),
15101517
]);
15111518

15121519
Ok(Arc::new(DefaultSettings {

src/query/settings/src/settings_getter_setter.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,4 +1139,8 @@ impl Settings {
11391139
pub fn get_max_aggregate_spill_level(&self) -> Result<u64> {
11401140
self.try_get_u64("max_aggregate_spill_level")
11411141
}
1142+
1143+
pub fn get_enable_experimental_table_ref(&self) -> Result<bool> {
1144+
Ok(self.try_get_u64("enable_experimental_table_ref")? != 0)
1145+
}
11421146
}

tests/sqllogictests/suites/ee/08_table_ref/08_0000_branch.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
## See the License for the specific language governing permissions and
1313
## limitations under the License.
1414

15+
statement ok
16+
set enable_experimental_table_ref=1;
17+
1518
statement ok
1619
DROP DATABASE IF EXISTS test_branch
1720

tests/sqllogictests/suites/ee/08_table_ref/08_0001_tag.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
## See the License for the specific language governing permissions and
1313
## limitations under the License.
1414

15+
statement ok
16+
set enable_experimental_table_ref=1;
17+
1518
statement ok
1619
DROP DATABASE IF EXISTS test_tag
1720

tests/sqllogictests/suites/mode/standalone/ee/explain_table_ref.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
## See the License for the specific language governing permissions and
1313
## limitations under the License.
1414

15+
statement ok
16+
set enable_experimental_table_ref=1;
17+
1518
statement ok
1619
CREATE OR REPLACE DATABASE test_table_ref;
1720

tests/suites/5_ee/01_vacuum/01_006_vacuum_table_with_refs.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ after vacuum
1515
4
1616
4
1717
2
18-
>>>> select c from test_vacuum_orphan_refs.a/b order by c
18+
>>>> set enable_experimental_table_ref=1; select c from test_vacuum_orphan_refs.a/b order by c
1919
1
2020
2
2121
after add pure orphan files

tests/suites/5_ee/01_vacuum/01_006_vacuum_table_with_refs.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ stmt "insert into test_vacuum_orphan_refs.a values (2),(3)"
1414
stmt "optimize table test_vacuum_orphan_refs.a compact"
1515

1616
FST_SNAPSHOT_ID=$(echo "select snapshot_id from fuse_snapshot('test_vacuum_orphan_refs','a') where row_count=2" | $BENDSQL_CLIENT_CONNECT)
17-
echo "alter table test_vacuum_orphan_refs.a create branch b at(snapshot => '$FST_SNAPSHOT_ID')" | $BENDSQL_CLIENT_CONNECT
17+
echo "set enable_experimental_table_ref=1; alter table test_vacuum_orphan_refs.a create branch b at(snapshot => '$FST_SNAPSHOT_ID')" | $BENDSQL_CLIENT_CONNECT
1818

1919
SNAPSHOT_LOCATION=$(echo "select snapshot_location from fuse_snapshot('test_vacuum_orphan_refs','a') limit 1" | $BENDSQL_CLIENT_CONNECT)
2020
PREFIX=$(echo "$SNAPSHOT_LOCATION" | cut -d'/' -f1-2)
@@ -35,7 +35,7 @@ ls -l /tmp/test_vacuum_orphan_refs/"$PREFIX"/_sg/ | wc -l
3535
ls -l /tmp/test_vacuum_orphan_refs/"$PREFIX"/_i_b_v2/ | wc -l
3636
ls -l /tmp/test_vacuum_orphan_refs/"$PREFIX"/_ref/ | wc -l
3737

38-
stmt "select c from test_vacuum_orphan_refs.a/b order by c"
38+
stmt "set enable_experimental_table_ref=1; select c from test_vacuum_orphan_refs.a/b order by c"
3939

4040
# simulates orphans
4141
mkdir -p /tmp/test_vacuum_orphan_refs/"$PREFIX"/_ref/1/

0 commit comments

Comments
 (0)