Skip to content

Commit

Permalink
[FLINK-23755][table] Modify the default value of table.dynamic-table-…
Browse files Browse the repository at this point in the history
…options.enabled to true

This closes apache#16887
  • Loading branch information
SteNicholas committed Aug 25, 2021
1 parent cd52056 commit d6484b9
Show file tree
Hide file tree
Showing 15 changed files with 2 additions and 43 deletions.
2 changes: 0 additions & 2 deletions docs/content.zh/docs/dev/table/sql/queries/hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ SQL hints 一般可以用于以下:

因此,它非常适合用于交互式终端中的特定查询,例如,在 SQL-CLI 中,你可以通过添加动态选项`/*+ OPTIONS('csv.ignore-parse-errors'='true') */`来指定忽略 CSV 源的解析错误。

<b>注意:</b>动态表选项默认值禁止使用,因为它可能会更改查询的语义。你需要将配置项 `table.dynamic-table-options.enabled` 显式设置为 `true`(默认值为 false),请参阅 [Configuration]({{< ref "docs/dev/table/config" >}}) 了解有关如何设置配置选项的详细信息。

<a name="syntax"></a>
### 语法
为了不破坏 SQL 兼容性,我们使用 Oracle 风格的 SQL hints 语法:
Expand Down
4 changes: 0 additions & 4 deletions docs/content/docs/dev/table/sql/queries/hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ these options can be specified flexibly in per-table scope within each query.
Thus it is very suitable to use for the ad-hoc queries in interactive terminal, for example, in the SQL-CLI,
you can specify to ignore the parse error for a CSV source just by adding a dynamic option `/*+ OPTIONS('csv.ignore-parse-errors'='true') */`.

<b>Note:</b> Dynamic table options default is forbidden to use because it may change the semantics of the query.
You need to set the config option `table.dynamic-table-options.enabled` to be `true` explicitly (default is false),
See the <a href="{{< ref "docs/dev/table/config" >}}">Configuration</a> for details on how to set up the config options.

### Syntax
In order to not break the SQL compatibility, we use the Oracle style SQL hint syntax:
```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</tr>
<tr>
<td><h5>table.dynamic-table-options.enabled</h5><br> <span class="label label-primary">Batch</span> <span class="label label-primary">Streaming</span></td>
<td style="word-wrap: break-word;">false</td>
<td style="word-wrap: break-word;">true</td>
<td>Boolean</td>
<td>Enable or disable the OPTIONS hint used to specify table options dynamically, if disabled, an exception would be thrown if any OPTIONS hint is specified</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private TableConfigOptions() {}
public static final ConfigOption<Boolean> TABLE_DYNAMIC_TABLE_OPTIONS_ENABLED =
key("table.dynamic-table-options.enabled")
.booleanType()
.defaultValue(false)
.defaultValue(true)
.withDescription(
"Enable or disable the OPTIONS hint used to specify table options "
+ "dynamically, if disabled, an exception would be thrown "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.apache.flink.table.api.TableConfig;
import org.apache.flink.table.api.TableSchema;
import org.apache.flink.table.api.ValidationException;
import org.apache.flink.table.api.config.TableConfigOptions;
import org.apache.flink.table.api.constraints.UniqueConstraint;
import org.apache.flink.table.catalog.Catalog;
import org.apache.flink.table.catalog.CatalogDatabaseImpl;
Expand Down Expand Up @@ -1321,9 +1320,6 @@ public void testCreateViewWithMatchRecognize() {

@Test
public void testCreateViewWithDynamicTableOptions() {
tableConfig
.getConfiguration()
.setBoolean(TableConfigOptions.TABLE_DYNAMIC_TABLE_OPTIONS_ENABLED, true);
Map<String, String> prop = new HashMap<>();
prop.put("connector", "values");
prop.put("bounded", "true");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ class CatalogTableITCase(isStreamingMode: Boolean) extends AbstractTestBase {

@Before
def before(): Unit = {
tableEnv.getConfig.getConfiguration.setBoolean(
TableConfigOptions.TABLE_DYNAMIC_TABLE_OPTIONS_ENABLED,
true)

tableEnv.getConfig
.getConfiguration
.setInteger(ExecutionConfigOptions.TABLE_EXEC_RESOURCE_DEFAULT_PARALLELISM, 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ class CatalogViewITCase(isStreamingMode: Boolean) extends AbstractTestBase {

@Before
def before(): Unit = {
tableEnv.getConfig.getConfiguration.setBoolean(
TableConfigOptions.TABLE_DYNAMIC_TABLE_OPTIONS_ENABLED,
true)

tableEnv.getConfig
.getConfiguration
.setInteger(ExecutionConfigOptions.TABLE_EXEC_RESOURCE_DEFAULT_PARALLELISM, 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ class LegacySinkTest extends TableTestBase {
|)
""".stripMargin)

util.tableEnv.getConfig.getConfiguration.setBoolean(
TableConfigOptions.TABLE_DYNAMIC_TABLE_OPTIONS_ENABLED, true)
util.tableEnv.executeSql(
s"""
|CREATE TABLE MySink (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,6 @@ class LegacyTableSourceTest extends TableTestBase {

@Test
def testTableHint(): Unit = {
util.tableEnv.getConfig.getConfiguration.setBoolean(
TableConfigOptions.TABLE_DYNAMIC_TABLE_OPTIONS_ENABLED, true)
val ddl =
s"""
|CREATE TABLE MyTable1 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ class TableSinkTest extends TableTestBase {
|)
""".stripMargin)

util.tableEnv.getConfig.getConfiguration.setBoolean(
TableConfigOptions.TABLE_DYNAMIC_TABLE_OPTIONS_ENABLED, true)
util.tableEnv.executeSql(
s"""
|CREATE TABLE MySink (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ class TableSourceTest extends TableTestBase {

@Test
def testTableHintWithDifferentOptions(): Unit = {
util.tableEnv.getConfig.getConfiguration.setBoolean(
TableConfigOptions.TABLE_DYNAMIC_TABLE_OPTIONS_ENABLED, true)
util.tableEnv.executeSql(
s"""
|CREATE TABLE MySink (
Expand Down Expand Up @@ -192,8 +190,6 @@ class TableSourceTest extends TableTestBase {

@Test
def testTableHintWithSameOptions(): Unit = {
util.tableEnv.getConfig.getConfiguration.setBoolean(
TableConfigOptions.TABLE_DYNAMIC_TABLE_OPTIONS_ENABLED, true)
util.tableEnv.executeSql(
s"""
|CREATE TABLE MySink (
Expand Down Expand Up @@ -224,8 +220,6 @@ class TableSourceTest extends TableTestBase {

@Test
def testTableHintWithDigestReuseForLogicalTableScan(): Unit = {
util.tableEnv.getConfig.getConfiguration.setBoolean(
TableConfigOptions.TABLE_DYNAMIC_TABLE_OPTIONS_ENABLED, true)
util.tableEnv.getConfig.getConfiguration.setBoolean(
RelNodeBlockPlanBuilder.TABLE_OPTIMIZER_REUSE_OPTIMIZE_BLOCK_WITH_DIGEST_ENABLED, true)
util.tableEnv.executeSql(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ class OptionsHintTest(param: Param)

@Before
def before(): Unit = {
util.tableEnv.getConfig.getConfiguration.setBoolean(
TableConfigOptions.TABLE_DYNAMIC_TABLE_OPTIONS_ENABLED,
true)
util.addTable(
s"""
|create table t1(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,6 @@ class LegacyTableSourceITCase extends BatchTestBase {

@Test
def testTableHint(): Unit = {
tEnv.getConfig.getConfiguration.setBoolean(
TableConfigOptions.TABLE_DYNAMIC_TABLE_OPTIONS_ENABLED, true)
val ddl =
s"""
|CREATE TABLE MyTable1 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ class TableSinkITCase extends BatchTestBase {
|)
""".stripMargin)

tEnv.getConfig.getConfiguration.setBoolean(
TableConfigOptions.TABLE_DYNAMIC_TABLE_OPTIONS_ENABLED, true)
val resultPath = BatchAbstractTestBase.TEMPORARY_FOLDER.newFolder().getAbsolutePath
tEnv.executeSql(
s"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,6 @@ class TableSourceITCase extends BatchTestBase {

@Test
def testTableHint(): Unit = {
tEnv.getConfig.getConfiguration.setBoolean(
TableConfigOptions.TABLE_DYNAMIC_TABLE_OPTIONS_ENABLED, true)
val resultPath = TEMPORARY_FOLDER.newFolder().getAbsolutePath
tEnv.executeSql(
s"""
Expand Down Expand Up @@ -344,8 +342,6 @@ class TableSourceITCase extends BatchTestBase {

@Test
def testTableHintWithLogicalTableScanReuse(): Unit = {
tEnv.getConfig.getConfiguration.setBoolean(
TableConfigOptions.TABLE_DYNAMIC_TABLE_OPTIONS_ENABLED, true)
tEnv.getConfig.getConfiguration.setBoolean(
RelNodeBlockPlanBuilder.TABLE_OPTIMIZER_REUSE_OPTIMIZE_BLOCK_WITH_DIGEST_ENABLED, true)
val resultPath = TEMPORARY_FOLDER.newFolder().getAbsolutePath
Expand Down

0 comments on commit d6484b9

Please sign in to comment.