@@ -6,35 +6,18 @@ import org.scalatest.funsuite.AnyFunSuite
6
6
import org .scalatest .matchers .should .Matchers
7
7
import pl .touk .nussknacker .engine .flink .table .FlinkSqlTableTestCases
8
8
import pl .touk .nussknacker .engine .flink .table .definition .FlinkDataDefinition .FlinkSqlDdlStatement .{
9
+ Connector ,
9
10
CreateTable ,
10
11
SqlString
11
12
}
12
- import pl .touk .nussknacker .engine .flink .table .definition .FlinkDdlParseError .{ ParseError , UnallowedStatement }
13
+ import pl .touk .nussknacker .engine .flink .table .definition .FlinkDataDefinitionCreationError . FlinkDdlParseError ._
13
14
import pl .touk .nussknacker .engine .flink .table .definition .FlinkDdlParserTest .syntacticallyInvalidSqlStatements
14
15
15
16
class FlinkDdlParserTest extends AnyFunSuite with Matchers {
16
17
17
- test(" return error for syntactically invalid statements" ) {
18
- syntacticallyInvalidSqlStatements.foreach { s =>
19
- FlinkDdlParser .parse(s) should matchPattern { case Invalid (NonEmptyList (ParseError (_), _)) => }
20
- }
21
- }
22
-
23
- test(" return multiple errors for multiple unallowed statements" ) {
24
- val sqlStatements = FlinkDdlParserTest .unallowedSqlStatements.mkString(" ;\n " )
25
- FlinkDdlParser .parse(sqlStatements) should matchPattern {
26
- case Invalid (NonEmptyList (UnallowedStatement (_), List (UnallowedStatement (_)))) =>
27
- }
28
- }
29
-
30
- test(" parses semantically invalid but parseable statements" ) {
31
- val sqlStatements = FlinkDdlParserTest .semanticallyIllegalButParseableStatements.mkString(" ;\n " )
32
- FlinkDdlParser .parse(sqlStatements) should matchPattern { case Valid (_) => }
33
- }
34
-
35
18
test(" parse valid create table statements" ) {
36
19
FlinkDdlParser .parse(FlinkSqlTableTestCases .unboundedKafkaTable) shouldBe Valid (
37
- List (CreateTable (SqlString (FlinkSqlTableTestCases .unboundedKafkaTableFormatted)))
20
+ List (CreateTable (SqlString (FlinkSqlTableTestCases .unboundedKafkaTableFormatted), Connector ( " kafka " ) ))
38
21
)
39
22
}
40
23
@@ -51,13 +34,45 @@ class FlinkDdlParserTest extends AnyFunSuite with Matchers {
51
34
s " ${FlinkSqlTableTestCases .PostgresCatalog .postgresCatalog}"
52
35
) shouldBe Valid (
53
36
List (
54
- CreateTable (SqlString (FlinkSqlTableTestCases .unboundedKafkaTableFormatted)),
55
- CreateTable (SqlString (FlinkSqlTableTestCases .unboundedDatagenTableFormatted)),
37
+ CreateTable (SqlString (FlinkSqlTableTestCases .unboundedKafkaTableFormatted), Connector ( " kafka " ) ),
38
+ CreateTable (SqlString (FlinkSqlTableTestCases .unboundedDatagenTableFormatted), Connector ( " datagen " ) ),
56
39
FlinkSqlTableTestCases .PostgresCatalog .postgresCatalogParsed
57
40
)
58
41
)
59
42
}
60
43
44
+ test(" parses semantically invalid but parseable statements" ) {
45
+ val sqlStatements = FlinkDdlParserTest .semanticallyIllegalButParseableStatements.mkString(" ;\n " )
46
+ FlinkDdlParser .parse(sqlStatements) should matchPattern { case Valid (_) => }
47
+ }
48
+
49
+ test(" return error for syntactically invalid statements" ) {
50
+ syntacticallyInvalidSqlStatements.foreach { s =>
51
+ FlinkDdlParser .parse(s) should matchPattern { case Invalid (NonEmptyList (ParseError (_), Nil )) => }
52
+ }
53
+ }
54
+
55
+ test(" return multiple errors for multiple unallowed statements" ) {
56
+ val sqlStatements = FlinkDdlParserTest .unallowedSqlStatements.mkString(" ;\n " )
57
+ FlinkDdlParser .parse(sqlStatements) should matchPattern {
58
+ case Invalid (NonEmptyList (UnallowedStatement (_), List (UnallowedStatement (_)))) =>
59
+ }
60
+ }
61
+
62
+ test(" return error for missing connector option" ) {
63
+ val sqlStatement = " CREATE TABLE testTable (str STRING) WITH ()"
64
+ FlinkDdlParser .parse(sqlStatement) should matchPattern {
65
+ case Invalid (NonEmptyList (MissingConnectorOption (_), Nil )) =>
66
+ }
67
+ }
68
+
69
+ test(" return error for missing catalog type" ) {
70
+ val sqlStatement = " CREATE CATALOG testCatalog WITH ()"
71
+ FlinkDdlParser .parse(sqlStatement) should matchPattern {
72
+ case Invalid (NonEmptyList (MissingCatalogTypeOption (_, _), Nil )) =>
73
+ }
74
+ }
75
+
61
76
}
62
77
63
78
object FlinkDdlParserTest {
@@ -86,9 +101,6 @@ object FlinkDdlParserTest {
86
101
|) WITH (
87
102
| 'connector' = 'datagen'
88
103
|) """ .stripMargin,
89
- s """ |CREATE TABLE testTableWithoutOptions (
90
- | col STRING
91
- |) """ .stripMargin,
92
104
s """ |CREATE TABLE testTableWithEmptyConnector (
93
105
| col STRING
94
106
|) WITH (
0 commit comments