public final class MetaModelHelper extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
containsNonSelectScalaFunctions(Query query)
Determines if a query contains
ScalarFunction s in any clause of
the query EXCEPT for the SELECT clause. |
static SelectItem[] |
createSelectItems(Column... columns) |
static Row |
executeSingleRowQuery(DataContext dataContext,
Query query)
Executes a single row query, like "SELECT COUNT(*), MAX(SOME_COLUMN) FROM
MY_TABLE" or similar.
|
static DataSet |
getAggregated(List<SelectItem> workSelectItems,
DataSet dataSet)
Applies aggregate values to a dataset.
|
static List<SelectItem> |
getAggregateFunctionSelectItems(Iterable<SelectItem> selectItems) |
static DataSet |
getCarthesianProduct(DataSet... fromDataSets) |
static DataSet |
getCarthesianProduct(DataSet[] fromDataSets,
FilterItem... filterItems) |
static DataSet |
getCarthesianProduct(DataSet[] fromDataSets,
Iterable<FilterItem> whereItems) |
static Column[] |
getColumnsBySuperType(Column[] columns,
SuperColumnType superColumnType) |
static Column[] |
getColumnsByType(Column[] columns,
ColumnType columnType) |
static DataSet |
getDistinct(DataSet dataSet) |
static List<SelectItem> |
getEvaluatedSelectItems(List<FilterItem> items) |
static DataSet |
getFiltered(DataSet dataSet,
FilterItem... filterItems) |
static DataSet |
getFiltered(DataSet dataSet,
Iterable<FilterItem> filterItems) |
static DataSet |
getGrouped(List<SelectItem> selectItems,
DataSet dataSet,
Collection<GroupByItem> groupByItems) |
static DataSet |
getGrouped(List<SelectItem> selectItems,
DataSet dataSet,
GroupByItem[] groupByItems) |
static DataSet |
getLeftJoin(DataSet ds1,
DataSet ds2,
FilterItem[] onConditions)
Performs a left join (aka left outer join) operation on two datasets.
|
static DataSet |
getOrdered(DataSet dataSet,
List<OrderByItem> orderByItems) |
static DataSet |
getOrdered(DataSet dataSet,
OrderByItem... orderByItems) |
static DataSet |
getPaged(DataSet dataSet,
int firstRow,
int maxRows) |
static DataSet |
getRightJoin(DataSet ds1,
DataSet ds2,
FilterItem[] onConditions)
Performs a right join (aka right outer join) operation on two datasets.
|
static List<SelectItem> |
getScalarFunctionSelectItems(Iterable<SelectItem> selectItems) |
static DataSet |
getSelection(List<SelectItem> selectItems,
DataSet dataSet) |
static DataSet |
getSelection(SelectItem[] selectItems,
DataSet dataSet) |
static SelectItem |
getSelectItemByAlias(Query query,
String alias)
This method returns the select item of the given alias name.
|
static Column[] |
getTableColumns(Table table,
Column[] columns)
Creates a subset array of columns, where only columns that are contained
within the specified table are included.
|
static Column[] |
getTableColumns(Table table,
Iterable<Column> columns)
Creates a subset array of columns, where only columns that are contained
within the specified table are included.
|
static List<FromItem> |
getTableFromItems(FromItem item) |
static FromItem[] |
getTableFromItems(Query q)
Examines a query and extracts an array of FromItem's that refer
(directly) to tables (hence Joined FromItems and SubQuery FromItems are
traversed but not included).
|
static Table[] |
getTables(Collection<Table> tableList,
Iterable<Column> columnList)
Creates an array of tables where all occurences of tables in the provided
list of tables and columns are included
|
static Table[] |
getTables(Column[] columns) |
static Table[] |
getTables(Iterable<Column> columns)
Converts a list of columns to a corresponding array of tables
|
static boolean |
isInformationSchema(Schema schema)
Determines if a schema is an information schema
|
static boolean |
isInformationSchema(String name)
Determines if a schema name is the name of an information schema
|
static Query |
parseQuery(DataContext dc,
String queryString) |
static List<Row> |
readDataSetFull(DataSet dataSet) |
public static Table[] getTables(Collection<Table> tableList, Iterable<Column> columnList)
public static boolean isInformationSchema(Schema schema)
schema
- public static boolean isInformationSchema(String name)
name
- public static Table[] getTables(Iterable<Column> columns)
columns
- the columns that the tables will be extracted frompublic static Column[] getTableColumns(Table table, Iterable<Column> columns)
table
- columns
- public static Column[] getTableColumns(Table table, Column[] columns)
table
- columns
- public static DataSet getCarthesianProduct(DataSet[] fromDataSets, Iterable<FilterItem> whereItems)
public static DataSet getCarthesianProduct(DataSet[] fromDataSets, FilterItem... filterItems)
public static DataSet getFiltered(DataSet dataSet, Iterable<FilterItem> filterItems)
public static DataSet getFiltered(DataSet dataSet, FilterItem... filterItems)
public static DataSet getSelection(List<SelectItem> selectItems, DataSet dataSet)
public static DataSet getSelection(SelectItem[] selectItems, DataSet dataSet)
public static DataSet getGrouped(List<SelectItem> selectItems, DataSet dataSet, Collection<GroupByItem> groupByItems)
public static DataSet getGrouped(List<SelectItem> selectItems, DataSet dataSet, GroupByItem[] groupByItems)
public static DataSet getAggregated(List<SelectItem> workSelectItems, DataSet dataSet)
workSelectItems
- all select items included in the processing of the query
(including those originating from other clauses than the
SELECT clause).dataSet
- public static List<SelectItem> getAggregateFunctionSelectItems(Iterable<SelectItem> selectItems)
public static List<SelectItem> getScalarFunctionSelectItems(Iterable<SelectItem> selectItems)
public static DataSet getOrdered(DataSet dataSet, List<OrderByItem> orderByItems)
public static DataSet getOrdered(DataSet dataSet, OrderByItem... orderByItems)
public static FromItem[] getTableFromItems(Query q)
q
- the query to examinepublic static Row executeSingleRowQuery(DataContext dataContext, Query query) throws MetaModelException
dataContext
- the DataContext object to use for executing the queryquery
- the query to executeMetaModelException
- if less or more than one Row is returned from the querypublic static DataSet getLeftJoin(DataSet ds1, DataSet ds2, FilterItem[] onConditions)
ds1
- the left datasetds2
- the right datasetonConditions
- the conditions to join bypublic static DataSet getRightJoin(DataSet ds1, DataSet ds2, FilterItem[] onConditions)
ds1
- the left datasetds2
- the right datasetonConditions
- the conditions to join bypublic static SelectItem[] createSelectItems(Column... columns)
public static Column[] getColumnsByType(Column[] columns, ColumnType columnType)
public static Column[] getColumnsBySuperType(Column[] columns, SuperColumnType superColumnType)
public static Query parseQuery(DataContext dc, String queryString)
public static List<SelectItem> getEvaluatedSelectItems(List<FilterItem> items)
public static SelectItem getSelectItemByAlias(Query query, String alias)
query
- public static boolean containsNonSelectScalaFunctions(Query query)
ScalarFunction
s in any clause of
the query EXCEPT for the SELECT clause. This is a handy thing to
determine because decorating with ScalarFunctionDataSet
only
gives you select-item evaluation so if the rest of the query is pushed to
an underlying datastore, then it may create issues.query
- Copyright © 2007–2017 The Apache Software Foundation. All rights reserved.