Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle double quote in z prefix resources #1412

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.util.List;
import java.util.stream.Collectors;

import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateTable;
import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateZtable;

public class PgsqlKafkaKeyAvroSchemaTemplate extends PgsqlKafkaAvroSchemaTemplate
{
Expand All @@ -31,7 +31,7 @@ public PgsqlKafkaKeyAvroSchemaTemplate(

public String generate(
String database,
CreateTable command)
CreateZtable command)
{
final String newNamespace = namespace.replace(DATABASE_PLACEHOLDER, database);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import jakarta.json.JsonValue;

import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Alter;
import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateTable;
import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateZtable;

public class PgsqlKafkaValueAvroSchemaTemplate extends PgsqlKafkaAvroSchemaTemplate
{
Expand All @@ -39,7 +39,7 @@ public PgsqlKafkaValueAvroSchemaTemplate(
}

public String generate(
CreateTable command)
CreateZtable command)
{
final String newNamespace = namespace.replace(DATABASE_PLACEHOLDER, command.schema());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
import io.aklivity.zilla.runtime.binding.pgsql.kafka.internal.types.stream.WindowFW;
import io.aklivity.zilla.runtime.binding.pgsql.parser.PgsqlParser;
import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Alter;
import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateTable;
import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateZtable;
import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Drop;
import io.aklivity.zilla.runtime.engine.EngineContext;
import io.aklivity.zilla.runtime.engine.binding.BindingHandler;
Expand Down Expand Up @@ -1336,7 +1336,7 @@ private void decodeCreateTopicCommand(
}
else if (server.commandsProcessed == 0)
{
final CreateTable createTopic = parser.parseCreateTable(statement);
final CreateZtable createTopic = parser.parseCreateTable(statement);
final String schema = createTopic.schema();
final String topic = createTopic.name();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
import io.aklivity.zilla.runtime.binding.pgsql.parser.listener.SqlShowListener;
import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Alter;
import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateFunction;
import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateTable;
import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateZfunction;
import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateZtable;
import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateZview;
import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Drop;

Expand Down Expand Up @@ -88,7 +88,7 @@ public String parseCommand(
return commandListener.command();
}

public CreateTable parseCreateTable(
public CreateZtable parseCreateTable(
String sql)
{
parser(sql, createTableListener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void enterRoot(
public void enterQualified_name(
PostgreSqlParser.Qualified_nameContext ctx)
{
String text = ctx.getText();
String text = ctx.getText().replace("\"", "");
String[] split = text.split(SCHEMA_PATTERN);
schema = split.length > 1 ? split[0] : PUBLIC_SCHEMA_NAME;
name = split.length > 1 ? split[1] : text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void enterRoot(
public void enterCreatezfunctionstmt(
PostgreSqlParser.CreatezfunctionstmtContext ctx)
{
String text = ctx.func_name().getText();
String text = ctx.func_name().getText().replace("\"", "");
String[] split = text.split(SCHEMA_PATTERN);
schema = split.length > 1 ? split[0] : PUBLIC_SCHEMA_NAME;
name = split.length > 1 ? split[1] : text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@

import io.aklivity.zilla.runtime.binding.pgsql.parser.PostgreSqlParser;
import io.aklivity.zilla.runtime.binding.pgsql.parser.PostgreSqlParserBaseListener;
import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateTable;
import io.aklivity.zilla.runtime.binding.pgsql.parser.model.TableColumn;
import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateZtable;
import io.aklivity.zilla.runtime.binding.pgsql.parser.model.ZtableColumn;

public class SqlCreateZtableTopicListener extends PostgreSqlParserBaseListener
{
private static final String PUBLIC_SCHEMA_NAME = "public";
private static final String SCHEMA_PATTERN = "\\.";

private final List<TableColumn> columns;
private final List<ZtableColumn> columns;
private final Set<String> primaryKeys;
private final TokenStream tokens;

Expand All @@ -46,9 +46,9 @@ public SqlCreateZtableTopicListener(
this.tokens = tokens;
}

public CreateTable table()
public CreateZtable table()
{
return new CreateTable(schema, name, columns, primaryKeys);
return new CreateZtable(schema, name, columns, primaryKeys);
}

@Override
Expand All @@ -65,7 +65,7 @@ public void enterRoot(
public void enterQualified_name(
PostgreSqlParser.Qualified_nameContext ctx)
{
String text = ctx.getText();
String text = ctx.getText().replace("\"", "");
String[] split = text.split(SCHEMA_PATTERN);
schema = split.length > 1 ? split[0] : PUBLIC_SCHEMA_NAME;
name = split.length > 1 ? split[1] : text;
Expand Down Expand Up @@ -112,7 +112,7 @@ private void addColumn(
constraints.add(tokens.getText(constraint.colconstraintelem()).toUpperCase());
}
}
columns.add(new TableColumn(columnName, dataType, constraints));
columns.add(new ZtableColumn(columnName, dataType, constraints));
}

private void addPrimaryKey(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void enterRoot(
public void enterCreatezviewstmt(
PostgreSqlParser.CreatezviewstmtContext ctx)
{
String text = ctx.create_mv_target().qualified_name().getText();
String text = ctx.create_mv_target().qualified_name().getText().replace("\"", "");
String[] split = text.split(SCHEMA_PATTERN);
schema = split.length > 1 ? split[0] : PUBLIC_SCHEMA_NAME;
name = split.length > 1 ? split[1] : text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void enterDropstmt(
{
ctx.any_name_list().any_name().forEach(n ->
{
String text = n.getText();
String text = n.getText().replace("\"", "");
String[] split = text.split(SCHEMA_PATTERN);
String schema = split.length > 1 ? split[0] : PUBLIC_SCHEMA_NAME;
String name = split.length > 1 ? split[1] : text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import java.util.List;
import java.util.Set;

public record CreateTable(
public record CreateZtable(
String schema,
String name,
List<TableColumn> columns,
List<ZtableColumn> columns,
Set<String> primaryKeys)
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import java.util.List;

public record TableColumn(
public record ZtableColumn(
String name,
String type,
List<String> constraints)
Expand Down
Loading