Skip to content

Commit a0fdfbf

Browse files
committed
Remove redundant code now that syntax roundtrip is more accurate
1 parent b867a2a commit a0fdfbf

File tree

3 files changed

+6
-24
lines changed

3 files changed

+6
-24
lines changed

src/dialect/hive.rs

-5
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,4 @@ impl Dialect for HiveDialect {
6666
fn supports_table_sample_before_alias(&self) -> bool {
6767
true
6868
}
69-
70-
/// See Hive <https://cwiki.apache.org/confluence/display/hive/languagemanual+sampling>
71-
fn supports_implicit_table_sample_method(&self) -> bool {
72-
true
73-
}
7469
}

src/dialect/mod.rs

-10
Original file line numberDiff line numberDiff line change
@@ -718,16 +718,6 @@ pub trait Dialect: Debug + Any {
718718
fn supports_table_sample_before_alias(&self) -> bool {
719719
false
720720
}
721-
722-
/// Returns true if this dialect support not specifying a table sample method. For example:
723-
///
724-
/// Implicit table sample method: `SELECT * FROM tbl TABLESAMPLE (10)`
725-
/// Explicit table sample method: `SELECT * FROM tbl TABLESAMPLE BERNOULLI (10)`
726-
///
727-
/// <https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#sample-clause>
728-
fn supports_implicit_table_sample_method(&self) -> bool {
729-
false
730-
}
731721
}
732722

733723
/// This represents the operators for which precedence must be defined

tests/sqlparser_common.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -12341,16 +12341,13 @@ fn parse_create_table_with_enum_types() {
1234112341

1234212342
#[test]
1234312343
fn test_table_sample() {
12344-
let dialects = all_dialects_where(|d| !d.supports_implicit_table_sample_method());
12345-
dialects.verified_stmt("SELECT * FROM tbl AS t TABLESAMPLE BERNOULLI (50)");
12346-
dialects.verified_stmt("SELECT * FROM tbl AS t TABLESAMPLE SYSTEM (50)");
12347-
dialects.verified_stmt("SELECT * FROM tbl AS t TABLESAMPLE SYSTEM (50) REPEATABLE (10)");
12348-
12349-
// The only dialect that supports implicit tablesample is Hive and it requires aliase after the table sample
12350-
let dialects = all_dialects_where(|d| {
12351-
d.supports_implicit_table_sample_method() && d.supports_table_sample_before_alias()
12352-
});
12344+
let dialects = all_dialects_where(|d| d.supports_table_sample_before_alias());
1235312345
dialects.verified_stmt("SELECT * FROM tbl TABLESAMPLE (50) AS t");
1235412346
dialects.verified_stmt("SELECT * FROM tbl TABLESAMPLE (50 ROWS) AS t");
1235512347
dialects.verified_stmt("SELECT * FROM tbl TABLESAMPLE (50 PERCENT) AS t");
12348+
12349+
let dialects = all_dialects_where(|d| !d.supports_table_sample_before_alias());
12350+
dialects.verified_stmt("SELECT * FROM tbl AS t TABLESAMPLE BERNOULLI (50)");
12351+
dialects.verified_stmt("SELECT * FROM tbl AS t TABLESAMPLE SYSTEM (50)");
12352+
dialects.verified_stmt("SELECT * FROM tbl AS t TABLESAMPLE SYSTEM (50) REPEATABLE (10)");
1235612353
}

0 commit comments

Comments
 (0)