MimirAdaptor now converts notebooks
parent
336fe2c554
commit
cc6be2fbfb
|
@ -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); }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue