Annotation Type QuerySqlTableFunction
-
@Documented @Retention(RUNTIME) @Target(METHOD) public @interface QuerySqlTableFunction
Annotates public methods in classes to be used in SQL queries as custom table functions. Annotated class must be registered usingCacheConfiguration.setSqlFunctionClasses(Class[]).Usage example:
public class MyTableFunctions { @QuerySqlTableFunction(columnTypes = {Float.class, String.class}, columnNames = {"F_VAL", "S_VAL"}) public static Iterable<Object[]> my_table(int i, Float f, String str) { return Arrays.asList( new Object[]{f, "code_" + (i * 10) + ": " + str}, new Object[]{null, "code_" + (i * 20) + ": " + str}, new Object[]{f, "code_" + (i * 30) + ": " + str} ); } } // Register in CacheConfiguration. cacheCfg.setSqlFunctionClasses(MyTableFunctions.class); // And use in queries. cache.query(new SqlFieldsQuery("select S_VAL from MY_TABLE(1, 5.0f, "ext") where F_VAL is not null"));Table function must return an
Iterableas a row set. Each row can be represented by anObject[]or by anCollection. Row length must match the defined number of column types. Row value types must match the defined column types or be able assigned to them.Note, the table functions are available currently only with Calcite.
- See Also:
QuerySqlFunction,SessionContextProviderResource
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description String[]columnNamesDefines column names of the returned SQL table representation.Class<?>[]columnTypesDefines column types of the returned SQL table representation.
-
-
-
Element Detail
-
columnTypes
Class<?>[] columnTypes
Defines column types of the returned SQL table representation. Number of the types must match number ofcolumnNames().- Returns:
- Table column types.
-
-
-
columnNames
String[] columnNames
Defines column names of the returned SQL table representation. Number of the names must match number ofcolumnTypes().- Returns:
- Table column names.
-
-
-
alias
String alias
Specifies alias for the table function name to be used form SQL queries. If no alias provided, the method name is used.- Returns:
- Alias for table function name.
- Default:
- ""
-
-