public class SqlConstraintUtils extends Object
SqlConstraint
,
used to generate constraints into SqlQuery
.Modifier and Type | Method and Description |
---|---|
static void |
addContextConstraint(SqlQuery sqlQuery,
AggStar aggStar,
Evaluator evaluator,
RolapCube baseCube,
boolean restrictMemberTypes)
For every restricting member in the current context, generates
a WHERE condition and a join to the fact table.
|
static void |
addMemberConstraint(SqlQuery sqlQuery,
RolapCube baseCube,
AggStar aggStar,
List<RolapMember> members,
boolean restrictMemberTypes,
boolean crossJoin,
boolean exclude)
Creates a "WHERE exp IN (...)" condition containing the values
of all parents.
|
static void |
addMemberConstraint(SqlQuery sqlQuery,
RolapCube baseCube,
AggStar aggStar,
RolapMember parent,
boolean restrictMemberTypes)
Creates a "WHERE parent = value" constraint.
|
static String |
constrainLevel(RolapLevel level,
SqlQuery query,
RolapCube baseCube,
AggStar aggStar,
String[] columnValue,
boolean caseSensitive)
Generates a sql expression constraining a level by some value
|
static String |
constrainLevel(RolapLevel level,
SqlQuery query,
RolapCube baseCube,
AggStar aggStar,
String columnValue,
boolean caseSensitive) |
static String |
constrainLevel2(SqlQuery query,
MondrianDef.Expression exp,
Dialect.Datatype datatype,
Comparable columnValue)
Generates a sql expression constraining a level by some value
|
static boolean |
containsCalculatedMember(List<Member> members) |
static boolean |
containsCalculatedMember(List<Member> members,
boolean allowExpandableMembers) |
static boolean |
containsValidMeasure(Exp... expressions) |
static void |
expandExpressions(Member member,
Exp expression,
Evaluator evaluator,
TupleConstraintStruct expandedSet) |
protected static Member[] |
expandMultiPositionSlicerMembers(Member[] members,
Evaluator evaluator) |
static void |
expandSetFromCalculatedMember(Evaluator evaluator,
Member member,
TupleConstraintStruct expandedSet) |
static void |
expandSupportedCalculatedMember(Member member,
Evaluator evaluator,
boolean disjointSlicerTuples,
TupleConstraintStruct expandedSet) |
static void |
expandSupportedCalculatedMember(Member member,
Evaluator evaluator,
TupleConstraintStruct expandedSet) |
static TupleConstraintStruct |
expandSupportedCalculatedMembers(List<Member> members,
Evaluator evaluator) |
static TupleConstraintStruct |
expandSupportedCalculatedMembers(List<Member> members,
Evaluator evaluator,
boolean disjointSlicerTuples) |
static String |
getColumnExpr(SqlQuery sqlQuery,
AggStar aggStar,
RolapStar.Column column)
Get the column expression from the AggStar if provided or the regular
table if not, and ensure table is in From
|
static Set<Member> |
getMembersNestedInMeasures(Set<Member> measures) |
static Map<Level,List<RolapMember>> |
getRoleConstraintMembers(SchemaReader schemaReader,
Member[] members) |
static Map<RolapLevel,List<RolapMember>> |
getRolesConstraints(Evaluator evaluator) |
protected static List<Member> |
getUniqueOrdinalMembers(List<Member> members)
Gets a list of unique ordinal cube members to make sure our
cell request isn't unsatisfiable, following the same logic
as RolapEvaluator
|
static boolean |
hasMultipleLevelSlicer(Evaluator evaluator) |
static boolean |
hasMultiPositionSlicer(List<Member> slicerMembers) |
static boolean |
isDisjointTuple(TupleList tupleList) |
static boolean |
isSupportedCalculatedMember(Member member)
Check to see if this is in a list of supported calculated members.
|
static boolean |
isSupportedExpressionForCalculatedMember(Exp expression) |
static void |
joinLevelTableToFactTable(SqlQuery sqlQuery,
RolapCube baseCube,
AggStar aggStar,
Evaluator e,
RolapCubeLevel level)
Ensures that the table of
level is joined to the fact
table |
static boolean |
measuresConflictWithMembers(Set<Member> measuresMembers,
CrossJoinArg[] cjArgs) |
static boolean |
measuresConflictWithMembers(Set<Member> measures,
Member[] members)
Returns true if any measure calculations in the first arg references
a dimension member with corresponding members in the second arg
which conflict with that member.
|
static boolean |
useTupleSlicer(RolapEvaluator evaluator) |
public static void addContextConstraint(SqlQuery sqlQuery, AggStar aggStar, Evaluator evaluator, RolapCube baseCube, boolean restrictMemberTypes)
sqlQuery
- the query to modifyaggStar
- Aggregate table, or null if query is against fact tablerestrictMemberTypes
- defines the behavior if the current context
contains calculated members. If true, thows an exception.evaluator
- Evaluatorpublic static boolean useTupleSlicer(RolapEvaluator evaluator)
public static Map<RolapLevel,List<RolapMember>> getRolesConstraints(Evaluator evaluator)
public static boolean isDisjointTuple(TupleList tupleList)
public static boolean hasMultipleLevelSlicer(Evaluator evaluator)
public static String getColumnExpr(SqlQuery sqlQuery, AggStar aggStar, RolapStar.Column column)
public static Map<Level,List<RolapMember>> getRoleConstraintMembers(SchemaReader schemaReader, Member[] members)
public static TupleConstraintStruct expandSupportedCalculatedMembers(List<Member> members, Evaluator evaluator)
public static TupleConstraintStruct expandSupportedCalculatedMembers(List<Member> members, Evaluator evaluator, boolean disjointSlicerTuples)
public static void expandSupportedCalculatedMember(Member member, Evaluator evaluator, TupleConstraintStruct expandedSet)
public static void expandSupportedCalculatedMember(Member member, Evaluator evaluator, boolean disjointSlicerTuples, TupleConstraintStruct expandedSet)
public static void expandExpressions(Member member, Exp expression, Evaluator evaluator, TupleConstraintStruct expandedSet)
public static boolean isSupportedCalculatedMember(Member member)
public static boolean isSupportedExpressionForCalculatedMember(Exp expression)
public static void expandSetFromCalculatedMember(Evaluator evaluator, Member member, TupleConstraintStruct expandedSet)
protected static List<Member> getUniqueOrdinalMembers(List<Member> members)
protected static Member[] expandMultiPositionSlicerMembers(Member[] members, Evaluator evaluator)
public static boolean containsCalculatedMember(List<Member> members, boolean allowExpandableMembers)
public static void joinLevelTableToFactTable(SqlQuery sqlQuery, RolapCube baseCube, AggStar aggStar, Evaluator e, RolapCubeLevel level)
level
is joined to the fact
tablesqlQuery
- sql query under constructionaggStar
- The aggStar to use, if any.e
- evaluator corresponding to querylevel
- level to be added to querypublic static void addMemberConstraint(SqlQuery sqlQuery, RolapCube baseCube, AggStar aggStar, RolapMember parent, boolean restrictMemberTypes)
sqlQuery
- the query to modifybaseCube
- base cube if virtualaggStar
- Definition of the aggregate table, or nullparent
- the list of parent membersrestrictMemberTypes
- defines the behavior if parent
is a calculated member. If true, an exception is thrownpublic static void addMemberConstraint(SqlQuery sqlQuery, RolapCube baseCube, AggStar aggStar, List<RolapMember> members, boolean restrictMemberTypes, boolean crossJoin, boolean exclude)
If this constraint is part of a native cross join, there are multiple constraining members, and the members comprise the cross product of all unique member keys referenced at each level, then generating IN expressions would result in incorrect results. In that case, "WHERE ((level1 = val1a AND level2 = val2a AND ...) OR (level1 = val1b AND level2 = val2b AND ...) OR ..." is generated instead.
sqlQuery
- the query to modifybaseCube
- base cube if virtualaggStar
- (not used)members
- the list of members for this constraintrestrictMemberTypes
- defines the behavior if parents
contains calculated members.
If true, and one of the members is calculated, an exception is thrown.crossJoin
- true if constraint is being generated as part of
a native crossjoinexclude
- whether to exclude the members in the SQL predicate.
e.g. not in { member list}.public static String constrainLevel(RolapLevel level, SqlQuery query, RolapCube baseCube, AggStar aggStar, String columnValue, boolean caseSensitive)
public static String constrainLevel(RolapLevel level, SqlQuery query, RolapCube baseCube, AggStar aggStar, String[] columnValue, boolean caseSensitive)
level
- the levelquery
- the query that the sql expression will be added tobaseCube
- base cube for virtual levelsaggStar
- aggregate star if availablecolumnValue
- value constraining the levelcaseSensitive
- if true, need to handle case sensitivity of the
member valuepublic static String constrainLevel2(SqlQuery query, MondrianDef.Expression exp, Dialect.Datatype datatype, Comparable columnValue)
exp
- Key expressiondatatype
- Key datatypequery
- the query that the sql expression will be added tocolumnValue
- value constraining the levelpublic static boolean measuresConflictWithMembers(Set<Member> measures, Member[] members)
public static Set<Member> getMembersNestedInMeasures(Set<Member> measures)
public static boolean measuresConflictWithMembers(Set<Member> measuresMembers, CrossJoinArg[] cjArgs)
public static boolean containsValidMeasure(Exp... expressions)
Copyright © 2018 Hitachi Vantara. All rights reserved.