Skip to content
Snippets Groups Projects
Commit f212f947 authored by Julien Lopez's avatar Julien Lopez
Browse files

Add a test join between pgsql and r, and a test class

parent b8fe5202
No related branches found
No related tags found
No related merge requests found
package com.oracle.truffle.r.test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import com.oracle.truffle.r.launcher.RscriptCommand;
/**
* This class runs FastR on every R file it can find in given directories (it will search
* recursively).
*/
public final class RTestSimple {
public static final void main(String[] args) {
System.out.println("Testing: " + args[0]);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final String expected;
try {
expected = String.join("\n", Files.readAllLines(Paths.get(args[0].replaceFirst("\\.[Rr]$", ".out"))));
RscriptCommand.doMain(new String[]{"Rscript", args[0]}, null, System.in, new PrintStream(baos), System.err);
if (expected.equals(baos.toString()))
System.out.println("[SUCCESS]");
else {
System.out.println("[FAILED] Expected: ");
System.out.println(expected);
System.out.println("got: ");
System.out.println(baos.toString());
}
} catch (IOException e) {
System.err.println("[FAILED] Could not find expected output.");
}
System.out.flush();
System.err.flush();
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
emp = new.tableRef("emp", "PostgreSQL", "postgre.config", "public")
dept = data.frame(deptno = c(1, 2, 3), loc = c("NEW YORK", "MIAMI", "SAN FRANCISCO"))
q = query.select(function (x) {
res = new.env()
res$ename = x$ename
res },
query.where(function (x) x$loc == "NEW YORK",
query.join(query.from(emp), dept, function (x,y) x$deptno == y$deptno)))
results = query.force(q)
print(results)
ename
1 CLARK
2 KING
3 MILLER
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment