This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_record' | |
require 'benchmark' | |
require 'faker' | |
ActiveRecord::Base.establish_connection( | |
adapter: 'fdbsql', database: 'test', host: 'localhost', pool: 20 | |
) | |
class User < ActiveRecord::Base | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.foundationdb.*; | |
import com.foundationdb.async.*; | |
import com.foundationdb.directory.*; | |
import com.foundationdb.tuple.*; | |
public class UniqueDemo | |
{ | |
public static void main(String[] args) { | |
FDB fdb = FDB.selectAPIVersion(200); | |
UniqueDemo app = new UniqueDemo(fdb); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.foundationdb.sql.parser.*; | |
import com.foundationdb.sql.StandardException; | |
public class TableFinder { | |
public static void main(String[] args) throws Exception { | |
SQLParser parser = new SQLParser(); | |
for(String sql : args) { | |
StatementNode node = parser.parseStatement(sql); | |
node.accept(new FromTablePrinter()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ java -cp fdb-sql-parser-1.2.0.jar:. QuerySplitter "select * from a,b where (a.name='xyz' or a.id>5 ) and (b.name='abc' or b.id=5)" | |
original: select * from a,b where (a.name='xyz' or a.id>5 ) and (b.name='abc' or b.id=5) | |
unparsed: SELECT * FROM a, b WHERE ((a.name = 'xyz') OR (a.id > 5)) AND ((b.name = 'abc') OR (b.id = 5)) | |
table a: SELECT * FROM a WHERE ((a.name = 'xyz') OR (a.id > 5)) AND (TRUE OR TRUE) | |
table b: SELECT * FROM b WHERE (TRUE OR TRUE) AND ((b.name = 'abc') OR (b.id = 5)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.foundationdb.sql.parser.BinaryRelationalOperatorNode; | |
import com.foundationdb.sql.parser.ConstantNode; | |
import com.foundationdb.sql.parser.NodeTypes; | |
import com.foundationdb.sql.parser.ParameterNode; | |
import com.foundationdb.sql.parser.Visitable; | |
import com.foundationdb.sql.parser.Visitor; | |
import java.util.LinkedHashMap; | |
import java.util.Map; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.foundationdb.sql.compiler.BooleanNormalizer; | |
import com.foundationdb.sql.parser.SQLParser; | |
import com.foundationdb.sql.parser.StatementNode; | |
import com.foundationdb.sql.unparser.NodeToString; | |
public class NormalizerDemo { | |
public static void main(String[] args) throws Exception { | |
if(args.length == 0) { | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.akiban.sql.parser.*; | |
public class ParserOrderBy { | |
public static void main(String[] args) throws Exception { | |
String sql = "Select id, refName from refRepo where property='SQL' order by id asc"; | |
System.out.println("SQL: " + sql); | |
SQLParser parser = new SQLParser(); | |
StatementNode node = parser.parseStatement(sql); | |
System.out.println(node); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// See: https://github.com/foundationdb/sql-parser | |
// | |
import com.foundationdb.sql.parser.*; | |
import com.foundationdb.sql.parser.SQLParserContext.*; | |
public class CustomCase { | |
public static class ColumnNamePrinter implements Visitor { | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"host": "<host>", | |
"port": "<port>", | |
"user": "<user>", | |
"pass": "<pass>" | |
} |