MimirAdaptor now converts notebooks

master
Oliver Kennedy 2016-06-25 22:00:50 -07:00
parent 336fe2c554
commit cc6be2fbfb
1 changed files with 25 additions and 0 deletions

View File

@ -16,7 +16,9 @@ package org.vizierdb.sql;
import java.util.*;
import scala.Enumeration;
import org.vizierdb.*;
import org.vizierdb.database.*;
import org.vizierdb.database.history.*;
import org.vizierdb.database.script.*;
import org.vizierdb.database.script.op.*;
import mimir.algebra.Table;
@ -156,6 +158,29 @@ public class MimirAdaptor {
return db.convert(raTree).toString();
}
public static String compileToSQL(VizUALScript script, Map<String, List<String>> schemas)
{
return compileToSQL(compileToRA(script, schemas), schemas);
}
public static String compileToSQL(Notebook notebook)
throws VizirDBException
{
VersionGraph history = notebook.getHistory();
VizUALScript script = history.getScript(history.getCurrentBranch().getIdentifier());
CSVFileLoad load = (CSVFileLoad)script.getOperation(0);
ColumnList cols = load.exec(notebook, null, 0).getColumns();
List<String> colNames = new ArrayList<String>();
for(Column col : cols){ colNames.add(col.getName()); }
Map<String, List<String>> schemas = new HashMap<String, List<String>>();
String tableName = load.getFileName().replaceFirst("\\..*$", "");
schemas.put(tableName, colNames);
schemas.put("dual", new ArrayList<String>());
return compileToSQL(script, schemas);
}
public static class UnsupportedFeature extends Exception {
public UnsupportedFeature(String msg) { super(msg); }
}