Skip to content

Commit

Permalink
[Rel v0.2] Migrate Java SDK files (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkastrinis authored Sep 3, 2024
1 parent a9e6305 commit 5f2ab26
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion rai-sdk-examples/src/test/resources/hello.rel
Original file line number Diff line number Diff line change
@@ -1 +1 @@
def R = "hello", "world"
def R {("hello", "world")}
16 changes: 8 additions & 8 deletions rai-sdk/src/main/java/com/relationalai/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -973,16 +973,16 @@ static void genSchemaConfig(StringBuilder builder, CsvOptions options) {
if (schema == null || schema.isEmpty())
return;
var count = 0;
builder.append("def config:schema =");
builder.append("def config[:schema]: {");
for (var entry : schema.entrySet()) {
if (count > 0)
builder.append(';');
var k = entry.getKey();
var v = entry.getValue();
builder.append(String.format("\n :%s, \"%s\"", k, v));
builder.append(String.format("\n (:%s, \"%s\")", k, v));
count++;
}
builder.append('\n');
builder.append("}\n");
}

// Returns a Rel literal for the given value.
Expand Down Expand Up @@ -1013,7 +1013,7 @@ static void genSyntaxOption(StringBuilder builder, String name, Object value) {
if (value == null)
return;
var lit = genLiteral(value);
var def = String.format("def config:syntax:%s = %s\n", name, lit);
var def = String.format("def config[:syntax, :%s]: %s\n", name, lit);
builder.append(def);
}

Expand All @@ -1032,8 +1032,8 @@ static String genLoadCsv(String relation, CsvOptions options) {
var builder = new StringBuilder();
genSchemaConfig(builder, options);
genSyntaxConfig(builder, options);
builder.append("def config:data = data\n");
builder.append(String.format("def insert:%s = load_csv[config]", relation));
builder.append("def config[:data]: data\n");
builder.append(String.format("def insert[:%s]: load_csv[config]", relation));
return builder.toString();
}

Expand Down Expand Up @@ -1071,8 +1071,8 @@ public TransactionResult loadCsv(
// Generate the Rel to load JSON data into a relation.
static String genLoadJson(String relation) {
var builder = new StringBuilder();
builder.append("def config:data = data\n");
builder.append(String.format("def insert:%s = load_json[config]", relation));
builder.append("def config[:data]: data\n");
builder.append(String.format("def insert[:%s]: load_json[config]", relation));
return builder.toString();
}

Expand Down
4 changes: 2 additions & 2 deletions rai-sdk/src/test/java/com/relationalai/DatabaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void testDatabase() throws HttpError, InterruptedException, IOException {
}

static final String testModel =
"def R = \"hello\", \"world\"";
"def R {(\"hello\", \"world\")}";

static final String testJson = "{" +
"\"name\":\"Amira\",\n" +
Expand Down Expand Up @@ -159,7 +159,7 @@ void testDatabase() throws HttpError, InterruptedException, IOException {
assertEquals(databaseCloneName, createRsp.name);
assertEquals("CREATED", createRsp.state);

// Make sure the data was cloned
// Make sure the data was cloned
var rsp = client.executeV1(databaseCloneName, engineName, "test_data", true);

Relation rel;
Expand Down
8 changes: 4 additions & 4 deletions rai-sdk/src/test/java/com/relationalai/LoadCsvTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class LoadCsvTest extends UnitTest {
assertEquals(0, loadRsp.output.length);
assertEquals(0, loadRsp.problems.length);

var rsp = client.executeV1(databaseName, engineName, "def output = sample");
var rsp = client.executeV1(databaseName, engineName, "def output {sample}");

Relation rel;

Expand Down Expand Up @@ -105,7 +105,7 @@ public class LoadCsvTest extends UnitTest {
assertEquals(0, loadRsp.output.length);
assertEquals(0, loadRsp.problems.length);

var rsp = client.executeV1(databaseName, engineName, "def output = sample_no_header");
var rsp = client.executeV1(databaseName, engineName, "def output {sample_no_header}");

Relation rel;

Expand Down Expand Up @@ -162,7 +162,7 @@ public class LoadCsvTest extends UnitTest {
assertEquals(0, loadRsp.output.length);
assertEquals(0, loadRsp.problems.length);

var rsp = client.executeV1(databaseName, engineName, "def output = sample_alt_syntax");
var rsp = client.executeV1(databaseName, engineName, "def output {sample_alt_syntax}");

Relation rel;

Expand Down Expand Up @@ -216,7 +216,7 @@ public class LoadCsvTest extends UnitTest {
assertEquals(0, loadRsp.output.length);
assertEquals(0, loadRsp.problems.length);

var rsp = client.executeV1(databaseName, engineName, "def output = sample");
var rsp = client.executeV1(databaseName, engineName, "def output {sample}");

Relation rel;

Expand Down
2 changes: 1 addition & 1 deletion rai-sdk/src/test/java/com/relationalai/LoadJsonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class LoadJsonTest extends UnitTest {
assertEquals(0, loadRsp.output.length);
assertEquals(0, loadRsp.problems.length);

var rsp = client.executeV1(databaseName, engineName, "def output = sample");
var rsp = client.executeV1(databaseName, engineName, "def output {sample}");

Relation rel;

Expand Down
2 changes: 1 addition & 1 deletion rai-sdk/src/test/java/com/relationalai/ModelsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@TestInstance(Lifecycle.PER_CLASS)
@ExtendWith({TestExtension.class})
public class ModelsTest extends UnitTest {
static final String testModel = "def R = \"hello\", \"world\"";
static final String testModel = "def R {(\"hello\", \"world\")}";

@Test void testModels() throws HttpError, InterruptedException, IOException {
var client = createClient();
Expand Down

0 comments on commit 5f2ab26

Please sign in to comment.