Skip to content

Bootstrap Risingwave zb_catalog #155

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

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 @@ -216,6 +216,8 @@ protected void invoke(

seedKafkaAndRegistry(config);

processInitSql(config);

processSql(config);

createConfigServerKafkaTopic(config);
Expand Down Expand Up @@ -338,10 +340,33 @@ private void startContainers(
System.out.println("Verified containers are healthy");
}

private void processInitSql(
ZillabaseConfig config)
{
PgsqlHelper pgsql = new PgsqlHelper(config.risingwave, "postgres");

pgsql.connect();

if (pgsql.connected)
{
pgsql.process("<initdb>",
"""
CREATE USER zillabase;
CREATE SCHEMA zb_catalog AUTHORIZATION postgres;
CREATE TABLE zb_catalog.zviews(
name VARCHAR PRIMARY KEY,
sql VARCHAR);
CREATE TABLE zb_catalog.ztables(
name VARCHAR PRIMARY KEY,
sql VARCHAR);
""");
}
}

private void processSql(
ZillabaseConfig config)
{
PgsqlHelper pgsql = new PgsqlHelper(config.risingwave);
PgsqlHelper pgsql = new PgsqlHelper(config.risingwave, "zillabase");

pgsql.connect();

Expand Down Expand Up @@ -2292,7 +2317,6 @@ CreateContainerCmd createContainer(
}
}


private static final class CreateRisingWaveFactory extends CreateContainerFactory
{
CreateRisingWaveFactory(
Expand Down Expand Up @@ -2708,12 +2732,13 @@ private final class PgsqlHelper


PgsqlHelper(
ZillabaseRisingWaveConfig config)
ZillabaseRisingWaveConfig config,
String user)
{
this.config = config;

Properties props = new Properties();
props.setProperty("user", "root");
props.setProperty("user", user);
props.setProperty("preferQueryMode", PreferQueryMode.SIMPLE.value());

this.url = "jdbc:postgresql://localhost:4567/%s".formatted(config.db);
Expand Down Expand Up @@ -2757,11 +2782,11 @@ void process(
String content = readSql(sql);
if (content != null)
{
execute(sql.getFileName().toString(), content);
process(sql.getFileName().toString(), content);
}
}

private void execute(
void process(
String filename,
String content)
{
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@
<dependency>
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java-core</artifactId>
<version>3.3.6</version>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java-transport-httpclient5</artifactId>
<version>3.3.6</version>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>jakarta.json.bind</groupId>
Expand Down
Loading