Search in sources :

Example 1 with VariableManager

use of com.teradata.jaqy.VariableManager in project jaqy by Teradata.

the class S3Utils method setSecret.

public static void setSecret(String secret, JaqyInterpreter interpreter) {
    VariableManager vm = interpreter.getVariableManager();
    vm.setVariable(S3SECRET_VAR, secret);
    // clear the current s3 client
    vm.setVariable(S3CLIENT_VAR, null);
}
Also used : VariableManager(com.teradata.jaqy.VariableManager)

Example 2 with VariableManager

use of com.teradata.jaqy.VariableManager in project jaqy by Teradata.

the class S3Utils method setAccess.

public static void setAccess(String access, JaqyInterpreter interpreter) {
    VariableManager vm = interpreter.getVariableManager();
    vm.setVariable(S3ACCESS_VAR, access);
    // clear the current s3 client
    vm.setVariable(S3CLIENT_VAR, null);
}
Also used : VariableManager(com.teradata.jaqy.VariableManager)

Example 3 with VariableManager

use of com.teradata.jaqy.VariableManager in project jaqy by Teradata.

the class S3Utils method getS3Builder.

public static AmazonS3ClientBuilder getS3Builder(JaqyInterpreter interpreter) {
    VariableManager vm = interpreter.getVariableManager();
    Variable var = vm.getVariable(S3BUILDER_VAR);
    if (var != null) {
        Object o = var.get();
        if (o instanceof AmazonS3ClientBuilder)
            return (AmazonS3ClientBuilder) o;
    }
    AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard();
    builder.withPathStyleAccessEnabled(true);
    vm.setVariable(S3BUILDER_VAR, builder);
    return builder;
}
Also used : VariableManager(com.teradata.jaqy.VariableManager) Variable(com.teradata.jaqy.interfaces.Variable) AmazonS3ClientBuilder(com.amazonaws.services.s3.AmazonS3ClientBuilder)

Example 4 with VariableManager

use of com.teradata.jaqy.VariableManager in project jaqy by Teradata.

the class WhereParserTest method test3.

@Test
public void test3() throws Exception {
    Globals globals = new Globals();
    JaqyInterpreter interpreter = new JaqyInterpreter(globals, null, null);
    VariableManager vm = interpreter.getVariableManager();
    ExpNode exp;
    exp = WhereParser.getExp("1 is NULL");
    exp.bind(null, vm, interpreter);
    Assert.assertFalse((Boolean) exp.get());
    exp = WhereParser.getExp("1 is not NULL");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
}
Also used : Globals(com.teradata.jaqy.Globals) VariableManager(com.teradata.jaqy.VariableManager) JaqyInterpreter(com.teradata.jaqy.JaqyInterpreter) ExpNode(com.teradata.jaqy.utils.exp.ExpNode) Test(org.junit.Test)

Example 5 with VariableManager

use of com.teradata.jaqy.VariableManager in project jaqy by Teradata.

the class WhereParserTest method test2.

@Test
public void test2() throws Exception {
    Globals globals = new Globals();
    JaqyInterpreter interpreter = new JaqyInterpreter(globals, null, null);
    VariableManager vm = interpreter.getVariableManager();
    ExpNode exp;
    exp = WhereParser.getExp("1 < any (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("1 < some (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("1 <= some (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("1 = some (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("1 <> some (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("1 > some (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertFalse((Boolean) exp.get());
    exp = WhereParser.getExp("1 >= some (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("1 < ALL (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertFalse((Boolean) exp.get());
    exp = WhereParser.getExp("1 <= ALL (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("1 = ALL (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertFalse((Boolean) exp.get());
    exp = WhereParser.getExp("1 <> ALL (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertFalse((Boolean) exp.get());
    exp = WhereParser.getExp("1 > ALL (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertFalse((Boolean) exp.get());
    exp = WhereParser.getExp("1 >= ALL (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertFalse((Boolean) exp.get());
    exp = WhereParser.getExp("1 IN (1, 2)");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("'abc' like 'a'");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
    exp = WhereParser.getExp("'abc' like 'a$'");
    exp.bind(null, vm, interpreter);
    Assert.assertFalse((Boolean) exp.get());
    exp = WhereParser.getExp("'abc' like 'a.*'");
    exp.bind(null, vm, interpreter);
    Assert.assertTrue((Boolean) exp.get());
}
Also used : Globals(com.teradata.jaqy.Globals) VariableManager(com.teradata.jaqy.VariableManager) JaqyInterpreter(com.teradata.jaqy.JaqyInterpreter) ExpNode(com.teradata.jaqy.utils.exp.ExpNode) Test(org.junit.Test)

Aggregations

VariableManager (com.teradata.jaqy.VariableManager)14 ExpNode (com.teradata.jaqy.utils.exp.ExpNode)5 Globals (com.teradata.jaqy.Globals)4 JaqyInterpreter (com.teradata.jaqy.JaqyInterpreter)4 Variable (com.teradata.jaqy.interfaces.Variable)4 Test (org.junit.Test)4 AmazonS3ClientBuilder (com.amazonaws.services.s3.AmazonS3ClientBuilder)2 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)1 AnonymousAWSCredentials (com.amazonaws.auth.AnonymousAWSCredentials)1 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)1 AmazonS3 (com.amazonaws.services.s3.AmazonS3)1