use of org.teiid.metadata.AggregateAttributes in project teiid by teiid.
the class FakeFunctionMetadataSource method getFunctionMethods.
public Collection<org.teiid.metadata.FunctionMethod> getFunctionMethods() {
List<org.teiid.metadata.FunctionMethod> methods = new ArrayList<org.teiid.metadata.FunctionMethod>();
methods.add(new // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"xyz", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"misc", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
PushDown.MUST_PUSHDOWN, // $NON-NLS-1$
FakeFunctionMetadataSource.class.getName(), // $NON-NLS-1$
"xyz", null, new FunctionParameter("out", "integer"), true, // $NON-NLS-1$ //$NON-NLS-2$
Determinism.DETERMINISTIC));
// $NON-NLS-1$ //$NON-NLS-2$
FunctionParameter p1 = new FunctionParameter("astring", "string");
// $NON-NLS-1$ //$NON-NLS-2$
FunctionParameter result = new FunctionParameter("trimstring", "string");
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
FunctionMethod method = new FunctionMethod("MYRTRIM", "", "", FakeFunctionMetadataSource.class.getName(), "myrtrim", new FunctionParameter[] { p1 }, result);
method.setPushdown(PushDown.CAN_PUSHDOWN);
methods.add(method);
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FunctionMethod method2 = new FunctionMethod("misc.namespace.func", "", "", null, null, new FunctionParameter[] { p1 }, result);
method2.setPushdown(PushDown.MUST_PUSHDOWN);
methods.add(method2);
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FunctionMethod method3 = new FunctionMethod("parsedate_", "", "", null, null, new FunctionParameter[] { p1 }, new FunctionParameter("", DataTypeManager.DefaultDataTypes.DATE));
method3.setPushdown(PushDown.MUST_PUSHDOWN);
methods.add(method3);
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FunctionMethod method4 = new FunctionMethod("FIRST_VALUE", "", "", null, null, new FunctionParameter[] { p1 }, result);
method4.setPushdown(PushDown.MUST_PUSHDOWN);
method4.setAggregateAttributes(new AggregateAttributes());
methods.add(method4);
return methods;
}
use of org.teiid.metadata.AggregateAttributes in project teiid by teiid.
the class ImpalaExecutionFactory method start.
@Override
public void start() throws TranslatorException {
super.start();
// $NON-NLS-1$
convert.addTypeMapping("tinyint", FunctionModifier.BYTE);
// $NON-NLS-1$
convert.addTypeMapping("smallint", FunctionModifier.SHORT);
// $NON-NLS-1$
convert.addTypeMapping("int", FunctionModifier.INTEGER);
// $NON-NLS-1$
convert.addTypeMapping("bigint", FunctionModifier.BIGINTEGER, FunctionModifier.LONG);
// $NON-NLS-1$
convert.addTypeMapping("boolean", FunctionModifier.BOOLEAN);
// $NON-NLS-1$
convert.addTypeMapping("double", FunctionModifier.DOUBLE);
// $NON-NLS-1$
convert.addTypeMapping("float", FunctionModifier.FLOAT);
// $NON-NLS-1$
convert.addTypeMapping("string", FunctionModifier.STRING);
// $NON-NLS-1$
convert.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP);
registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("lower"));
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("upper"));
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new AliasModifier("substr"));
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.CURDATE, new AliasModifier("unix_timestamp"));
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("isnull"));
// $NON-NLS-1$ //$NON-NLS-2$
registerFunctionModifier("string_agg", new AliasModifier("group_concat"));
// $NON-NLS-1$
addPushDownFunction(IMPALA, "lower", STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "upper", STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "positive", INTEGER, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "positive", DOUBLE, DOUBLE);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "negitive", INTEGER, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "negitive", DOUBLE, DOUBLE);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "ln", DOUBLE, DOUBLE);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "reverse", STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "space", STRING, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "hex", STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "unhex", STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "bin", STRING, LONG);
// date functions
// $NON-NLS-1$
addPushDownFunction(IMPALA, "add_months", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "adddate", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "date_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "date_part", INTEGER, STRING, TIMESTAMP);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "date_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "datediff", INTEGER, STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "day", INTEGER, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "dayofyear", INTEGER, TIMESTAMP);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "days_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "days_add", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "days_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "days_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "extract", INTEGER, TIMESTAMP, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "from_unixtime", STRING, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "from_unixtime", STRING, LONG, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "from_utc_timestamp", TIMESTAMP, TIMESTAMP, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "hour", INTEGER, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "hours_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "hours_add", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "hours_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "hours_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "microseconds_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "microseconds_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "milliseconds_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "milliseconds_add", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "milliseconds_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "milliseconds_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "minute", INTEGER, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "minutes_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "minutes_add", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "minutes_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "minutes_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "month", INTEGER, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "months_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "months_add", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "months_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "months_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "nanoseconds_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "nanoseconds_add", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "nanoseconds_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "nanoseconds_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "second", INTEGER, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "seconds_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "seconds_add", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "seconds_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "seconds_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "subdate", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "to_date", STRING, TIMESTAMP);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "to_utc_timestamp", TIMESTAMP, TIMESTAMP, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "trunc", TIMESTAMP, TIMESTAMP, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "unix_timestamp", INTEGER, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "unix_timestamp", INTEGER, STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "unix_timestamp", INTEGER, TIMESTAMP);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "weekofyear", INTEGER, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "weeks_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "weeks_add", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "weeks_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "weeks_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "years_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "years_add", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "years_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "years_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "conv", STRING, LONG, INTEGER, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "greatest", STRING, STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "greatest", TIMESTAMP, TIMESTAMP, TIMESTAMP);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "greatest", LONG, LONG, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "least", STRING, STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "least", TIMESTAMP, TIMESTAMP, TIMESTAMP);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "least", LONG, LONG, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "log2", STRING, DOUBLE);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "pow", DOUBLE, DOUBLE);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "quotient", INTEGER, INTEGER, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "radians", DOUBLE, DOUBLE);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "sign", INTEGER, DOUBLE);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "parse_url", STRING, STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "regexp_extract", STRING, STRING, STRING, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "regexp_replace", STRING, STRING, STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "group_concat", STRING, STRING, STRING).setAggregateAttributes(new AggregateAttributes());
// $NON-NLS-1$
addPushDownFunction(IMPALA, "concat_ws", STRING, STRING, STRING).setVarArgs(true);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "concat", STRING, STRING).setVarArgs(true);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "initcap", STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "instr", INTEGER, STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "find_in_set", INTEGER, STRING, STRING);
// standard function form of several predicates
// $NON-NLS-1$ //$NON-NLS-2$
addPushDownFunction(IMPALA, "ilike", BOOLEAN, STRING, STRING).setProperty(SQLStringVisitor.TEIID_NATIVE_QUERY, "($1 ilike $2)");
// $NON-NLS-1$ //$NON-NLS-2$
addPushDownFunction(IMPALA, "rlike", BOOLEAN, STRING, STRING).setProperty(SQLStringVisitor.TEIID_NATIVE_QUERY, "($1 rlike $2)");
// $NON-NLS-1$ //$NON-NLS-2$
addPushDownFunction(IMPALA, "iregexp", BOOLEAN, STRING, STRING).setProperty(SQLStringVisitor.TEIID_NATIVE_QUERY, "($1 iregexp $2)");
}
use of org.teiid.metadata.AggregateAttributes in project teiid by teiid.
the class BaseHiveExecutionFactory method addAggregatePushDownFunction.
protected FunctionMethod addAggregatePushDownFunction(String qualifier, String name, String returnType, String... paramTypes) {
FunctionMethod method = addPushDownFunction(qualifier, name, returnType, paramTypes);
AggregateAttributes attr = new AggregateAttributes();
attr.setAnalytic(true);
method.setAggregateAttributes(attr);
return method;
}
use of org.teiid.metadata.AggregateAttributes in project teiid by teiid.
the class TestAggregateProcessing method testUserDefined.
@Test
public void testUserDefined() throws Exception {
MetadataStore ms = RealMetadataFactory.example1Store();
Schema s = ms.getSchemas().get("PM1");
AggregateAttributes aa = addAgg(s, "myagg", SumAll.class, DataTypeManager.DefaultDataTypes.INTEGER).getAggregateAttributes();
addAgg(s, "myagg2", LongSumAll.class, DataTypeManager.DefaultDataTypes.LONG);
TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(ms, "test");
Command c = TestResolver.helpResolve("select myagg2(distinct e2) from pm1.g1", metadata);
assertEquals(DataTypeManager.DefaultDataClasses.LONG, c.getProjectedSymbols().get(0).getType());
// must be in agg form
TestValidator.helpValidate("SELECT myagg(e2) from pm1.g1", new String[] {}, metadata);
// run validations over default AggregateAttributes
TestValidator.helpValidate("SELECT myagg(distinct e2) from pm1.g1", new String[] { "myagg(DISTINCT e2)" }, metadata);
TestValidator.helpValidate("SELECT myagg(e2 order by e1) from pm1.g1", new String[] { "myagg(ALL e2 ORDER BY e1)" }, metadata);
TestValidator.helpValidate("SELECT myagg(ALL e2, e2) over () from pm1.g1", new String[] {}, metadata);
aa.setAllowsDistinct(true);
aa.setAllowsOrderBy(true);
TestValidator.helpValidate("SELECT myagg(distinct e2) from pm1.g1", new String[] {}, metadata);
TestValidator.helpValidate("SELECT myagg(e2 order by e1) from pm1.g1", new String[] {}, metadata);
aa.setAnalytic(true);
TestValidator.helpValidate("SELECT myagg(distinct e2) from pm1.g1", new String[] { "myagg(DISTINCT e2)" }, metadata);
TestValidator.helpValidate("SELECT myagg(e2, e2) over () from pm1.g1", new String[] {}, metadata);
aa.setAnalytic(false);
// Create expected results
List[] expected = new List[] { Arrays.asList(6, 6), Arrays.asList(8, 8) };
// Construct data manager with data
FakeDataManager dataManager = new FakeDataManager();
sampleData1(dataManager);
ProcessorPlan plan = helpGetPlan("select myagg(all e2, e2 order by e1), myagg(e2, e2) from pm1.g1 group by e3", metadata);
helpProcess(plan, dataManager, expected);
}
use of org.teiid.metadata.AggregateAttributes in project teiid by teiid.
the class TestAggregateProcessing method addAgg.
private FunctionMethod addAgg(Schema s, String name, Class<?> clazz, String returns) {
FunctionMethod fm = new FunctionMethod();
fm.setName(name);
fm.setInvocationClass(clazz.getName());
fm.setInvocationMethod("addInput");
FunctionParameter fp = new FunctionParameter();
fp.setType(DataTypeManager.DefaultDataTypes.INTEGER);
fp.setName("arg");
fp.setVarArg(true);
fm.getInputParameters().add(fp);
FunctionParameter fpout = new FunctionParameter();
fpout.setType(returns);
fpout.setName("outp");
fm.setOutputParameter(fpout);
AggregateAttributes aa = new AggregateAttributes();
fm.setAggregateAttributes(aa);
s.getFunctions().put(fm.getName(), fm);
return fm;
}
Aggregations