-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
315 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
...e/binding/risingwave/internal/statement/RisingwaveCreateMaterializedViewTemplateTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
|
||
import io.aklivity.zilla.runtime.binding.pgsql.parser.module.TableInfo; | ||
import io.aklivity.zilla.runtime.binding.pgsql.parser.module.ViewInfo; | ||
|
||
public class RisingwaveCreateMaterializedViewTemplateTest | ||
{ | ||
private final RisingwaveCreateMaterializedViewTemplate template = new RisingwaveCreateMaterializedViewTemplate(); | ||
|
||
@Test | ||
public void shouldGenerateMaterializedViewWithValidViewInfo() | ||
{ | ||
ViewInfo viewInfo = new ViewInfo("test_view", "SELECT * FROM test_table"); | ||
String expectedSQL = """ | ||
CREATE MATERIALIZED VIEW IF NOT EXISTS test_view AS SELECT * FROM test_table;\u0000"""; | ||
|
||
String actualSQL = template.generate(viewInfo); | ||
|
||
assertEquals(expectedSQL, actualSQL); | ||
} | ||
|
||
@Ignore("TODO") | ||
@Test | ||
public void shouldGenerateMaterializedViewWithValidTableInfo() | ||
{ | ||
TableInfo tableInfo = new TableInfo( | ||
"test_table", | ||
Map.of("id", "INT", "name", "STRING"), | ||
Set.of("id")); | ||
String expectedSQL = """ | ||
CREATE MATERIALIZED VIEW IF NOT EXISTS test_table_view AS SELECT id, name FROM test_table_source;\u0000"""; | ||
|
||
String actualSQL = template.generate(tableInfo); | ||
|
||
assertEquals(expectedSQL, actualSQL); | ||
} | ||
|
||
@Test | ||
public void shouldGenerateMaterializedViewWithEmptyColumns() | ||
{ | ||
TableInfo tableInfo = new TableInfo("empty_table", Map.of(), Set.of()); | ||
String expectedSQL = """ | ||
CREATE MATERIALIZED VIEW IF NOT EXISTS empty_table_view AS SELECT * FROM empty_table_source;\u0000"""; | ||
|
||
String actualSQL = template.generate(tableInfo); | ||
|
||
assertEquals(expectedSQL, actualSQL); | ||
} | ||
|
||
@Test | ||
public void shouldGenerateMaterializedViewWithIncludes() | ||
{ | ||
Map<String, String> columns = new LinkedHashMap<>(); | ||
columns.put("id", "INT"); | ||
columns.put("zilla_correlation_id", "VARCHAR"); | ||
columns.put("zilla_identity", "VARCHAR"); | ||
columns.put("timestamp", "TIMESTAMP"); | ||
|
||
TableInfo tableInfo = new TableInfo("test_table", columns, Set.of("id")); | ||
String expectedSQL = "CREATE MATERIALIZED VIEW IF NOT EXISTS test_table_view AS SELECT id," + | ||
" COALESCE(zilla_correlation_id, zilla_correlation_id_header::varchar) as zilla_correlation_id," + | ||
" COALESCE(zilla_identity, zilla_identity_header::varchar) as zilla_identity, timestamp" + | ||
" FROM test_table_source;\u0000"; | ||
|
||
String actualSQL = template.generate(tableInfo); | ||
|
||
assertEquals(expectedSQL, actualSQL); | ||
} | ||
} |
Oops, something went wrong.