Package org.teiid.translator.phoenix
Class PhoenixExecutionFactory
- java.lang.Object
-
- org.teiid.translator.ExecutionFactory<DataSource,Connection>
-
- org.teiid.translator.jdbc.JDBCExecutionFactory
-
- org.teiid.translator.phoenix.PhoenixExecutionFactory
-
- Direct Known Subclasses:
HBaseExecutionFactory
@Translator(name="phoenix", description="A translator for Phoenix/HBase") public class PhoenixExecutionFactory extends JDBCExecutionFactory
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.teiid.translator.jdbc.JDBCExecutionFactory
JDBCExecutionFactory.StructRetrieval
-
Nested classes/interfaces inherited from class org.teiid.translator.ExecutionFactory
ExecutionFactory.Format, ExecutionFactory.NullOrder, ExecutionFactory.SupportedJoinCriteria, ExecutionFactory.TransactionSupport
-
-
Field Summary
Fields Modifier and Type Field Description static String
PHOENIX
static Version
V_4_8
-
Fields inherited from class org.teiid.translator.jdbc.JDBCExecutionFactory
DEFAULT_MAX_DEPENDENT_PREDICATES, DEFAULT_MAX_IN_CRITERIA, DEFAULT_TIME_ZONE, dialect
-
Fields inherited from class org.teiid.translator.ExecutionFactory
DEFAULT_MAX_FROM_GROUPS, DEFAULT_MAX_IN_CRITERIA_SIZE, DEFAULT_MAX_PROJECTED_COLUMNS
-
-
Constructor Summary
Constructors Constructor Description PhoenixExecutionFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bindValue(PreparedStatement pstmt, Object param, Class<?> paramType, int i)
Sets prepared statement parameter i with param.protected JDBCMetadataProcessor
createMetadataProcessor()
JDBCUpdateExecution
createUpdateExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Connection conn)
Character
getRequiredLikeEscape()
The required escape character or null if all are supported.PhoenixSQLConversionVisitor
getSQLConversionVisitor()
Create theSQLConversionVisitor
that will perform translation.List<String>
getSupportedFunctions()
Get list of all supported function names.void
initCapabilities(Connection connection)
Will be called byExecutionFactory.start()
with a null connection if a source connection is notExecutionFactory.isSourceRequiredForCapabilities()
Object
retrieveValue(ResultSet results, int columnIndex, Class<?> expectedType)
The Phoenix driver has issues using a calendar object.void
start()
Initialize the connector with supplied configurationboolean
supportsInsertWithQueryExpression()
boolean
supportsRowLimit()
Gets whether the connector can limit the number of rows returned by a query.boolean
supportsRowOffset()
Gets whether the connector supports a SQL clause (similar to the LIMIT with an offset) that can return result sets that start in the middle of the resulting rows returned by a queryboolean
supportsScalarSubqueryProjection()
If a scalar subquery can be projected.boolean
supportsUpsert()
List<?>
translate(LanguageObject obj, ExecutionContext context)
Adding a specific workaround for just Pheonix and BigDecimal.List<?>
translateCommand(Command command, ExecutionContext context)
Return a List of translated parts (LanguageObject
s and Objects), or null if to rely on the default translation.List<?>
translateLimit(Limit limit, ExecutionContext context)
Return a List of translated parts (LanguageObject
s and Objects), or null if to rely on the default translation.String
translateLiteralBoolean(Boolean booleanValue)
Subclasses should override this method to provide a different sql translation of the literal boolean value.String
translateLiteralDate(Date dateValue)
It doesn't appear that the time component is needed, but for consistency with their documentation, we'll add it.String
translateLiteralTime(Time timeValue)
A date component is required, so create a new Timestamp insteadString
translateLiteralTimestamp(Timestamp timestampValue)
Subclasses should override this method to provide a different sql translation of the literal timestamp value.protected boolean
usesDatabaseVersion()
-
Methods inherited from class org.teiid.translator.jdbc.JDBCExecutionFactory
addSourceComment, afterInitialConnectionObtained, closeConnection, convertObject, createDirectExecution, createProcedureExecution, createResultSetExecution, createTempTable, executeStoredProcedure, formatDateValue, formatDateValue, getCommentFormat, getConnection, getCreateTemporaryTablePostfix, getCreateTemporaryTableString, getCreateTempTableSQL, getDatabaseCalendar, getDatabaseTimeZone, getDatabaseVersion, getDefaultNullOrder, getDefaultSupportedFunctions, getDialect, getFunctionModifiers, getHibernateDialectClassName, getLateralKeyword, getLikeRegexString, getMaxPreparedInsertBatchSize, getMetadata, getMetadataProcessor, getRemovePushdownCharacters, getSetOperationString, getSourceComment, getStructRetrieval, getTemporaryTableName, getTimestampNanoPrecision, getVersion, hasTimeType, intializeConnectionAfterCancel, isCharacterType, isDefaultTimeZone, isEnableDependentJoins, isExtendedAscii, isNonAscii, isNonAscii, isNonAsciiFunction, isSourceRequired, isSourceRequiredForCapabilities, isTrimStrings, loadedTemporaryTable, obtainedConnection, registerFunctionModifier, registerSpecificTypeOfOutParameter, replaceElementName, retrieveGeographyValue, retrieveGeographyValue, retrieveGeometryValue, retrieveGeometryValue, retrieveValue, setCommentFormat, setDatabaseTimeZone, setDatabaseVersion, setDatabaseVersion, setEnableDependentJoins, setFetchSize, setMaxPreparedInsertBatchSize, setRemovePushdownCharacters, setStructRetrieval, setTrimStrings, setUseBindingsForDependentJoin, setUseBindVariables, setUseCommentsInSourceQuery, supportsAggregatesAvg, supportsAggregatesCount, supportsAggregatesCountStar, supportsAggregatesDistinct, supportsAggregatesMax, supportsAggregatesMin, supportsAggregatesSum, supportsAliasedTable, supportsBatchedUpdates, supportsBooleanExpressions, supportsBulkUpdate, supportsCompareCriteriaEquals, supportsCompareCriteriaOrdered, supportsCorrelatedSubqueries, supportsDependentJoins, supportsExistsCriteria, supportsFullDependentJoins, supportsGeneratedKeys, supportsGeneratedKeys, supportsGroupBy, supportsHaving, supportsInCriteria, supportsInCriteriaSubquery, supportsInlineViews, supportsIsNullCriteria, supportsLikeCriteria, supportsLikeCriteriaEscapeCharacter, supportsNotCriteria, supportsOrCriteria, supportsOrderByUnrelated, supportsProcedureParameterExpression, supportsQuantifiedCompareCriteriaAll, supportsQuantifiedCompareCriteriaSome, supportsScalarSubqueries, supportsSearchedCaseExpressions, supportsSelectExpression, supportsSelfJoins, supportsSetQueryOrderBy, supportsUnions, tempTableRequiresTransaction, translateGeographyLiteral, translateGeographyParameter, translateGeographySelect, translateGeometryLiteral, translateGeometryParameter, translateGeometrySelect, translateLiteralBinaryType, useAsInGroupAlias, useBindingsForDependentJoin, useBindVariables, useColumnNamesForGeneratedKeys, useCommentsInSourceQuery, useNBindingType, useParensForJoins, useParensForSetQueries, usePreparedStatements, useScientificNotation, useSelectLimit, useStreamsForLobs, useUnicodePrefix, useWithRollup
-
Methods inherited from class org.teiid.translator.ExecutionFactory
addPushDownFunction, areLobsUsableAfterClose, createExecution, getCacheDirective, getCollationLocale, getConnection, getDirectQueryProcedureName, getExcludedCommonTableExpressionName, getInstance, getLanguageFactory, getMaxDependentInPredicates, getMaxFromGroups, getMaxInCriteriaSize, getMaxProjectedColumns, getNativeQueryProcedureName, getPushDownFunctions, getSupportedJoinCriteria, getTransactionSupport, getTypeFacility, isCopyLobs, isForkable, isImmutable, isSourceRequiredForMetadata, isThreadBound, requiresCriteria, returnsSingleUpdateCount, setCollationLocale, setCopyLobs, setDirectQueryProcedureName, setExcludedCommonTableExpressionName, setImmutable, setMaxDependentInPredicates, setMaxInCriteriaSize, setNativeQueryProcedureName, setRequiresCriteria, setSourceRequired, setSourceRequiredForMetadata, setSupportedJoinCriteria, setSupportsDirectQueryProcedure, setSupportsFullOuterJoins, setSupportsInnerJoins, setSupportsNativeQueries, setSupportsOrderBy, setSupportsOuterJoins, setSupportsSelectDistinct, setThreadBound, setTransactionSupport, supportsAdvancedOlapOperations, supportsAggregatesCountBig, supportsAggregatesEnhancedNumeric, supportsArrayAgg, supportsArrayType, supportsCommonTableExpressions, supportsCompareCriteriaOrderedExclusive, supportsConvert, supportsCorrelatedSubqueryLimit, supportsDirectQueryProcedure, supportsElementaryOlapOperations, supportsExcept, supportsFormatLiteral, supportsFullOuterJoins, supportsFunctionsInGroupBy, supportsGeographyType, supportsGroupByMultipleDistinctAggregates, supportsGroupByRollup, supportsInnerJoins, supportsIntersect, supportsIsDistinctCriteria, supportsLateralJoin, supportsLateralJoinCondition, supportsLikeRegex, supportsListAgg, supportsMultipleOpenExecutions, supportsNativeQueries, supportsOnlyCorrelatedSubqueries, supportsOnlyFormatLiterals, supportsOnlyLateralJoinProcedure, supportsOnlyLiteralComparison, supportsOnlySingleTableGroupBy, supportsOnlyTimestampAddLiteral, supportsOrderBy, supportsOrderByNullOrdering, supportsOrderByWithExtendedGrouping, supportsOuterJoins, supportsPartialFiltering, supportsProcedureTable, supportsRecursiveCommonTableExpressions, supportsSelectDistinct, supportsSelectExpressionArrayType, supportsSelectWithoutFrom, supportsSetQueryLimitOffset, supportsSimilarTo, supportsStringAgg, supportsSubqueryCommonTableExpressions, supportsSubqueryInOn, supportsWindowDistinctAggregates, supportsWindowFrameClause, supportsWindowFunctionCumeDist, supportsWindowFunctionNthValue, supportsWindowFunctionNtile, supportsWindowFunctionPercentRank, supportsWindowOrderByWithAggregates, useAnsiJoin
-
-
-
-
Method Detail
-
start
public void start() throws TranslatorException
Description copied from class:ExecutionFactory
Initialize the connector with supplied configuration- Overrides:
start
in classJDBCExecutionFactory
- Throws:
TranslatorException
-
getSupportedFunctions
public List<String> getSupportedFunctions()
Description copied from class:ExecutionFactory
Get list of all supported function names. Arithmetic functions have names like "+".- Overrides:
getSupportedFunctions
in classJDBCExecutionFactory
- See Also:
for a listing of system pushdown functions. Note that not all system functions are listed as some functions will use a common name such as CONCAT vs. the || operator, and other functions will be rewritten and not pushed down, such as SPACE. Note: User defined functions should be specified fully qualified.
-
initCapabilities
public void initCapabilities(Connection connection) throws TranslatorException
Description copied from class:ExecutionFactory
Will be called byExecutionFactory.start()
with a null connection if a source connection is notExecutionFactory.isSourceRequiredForCapabilities()
- Overrides:
initCapabilities
in classJDBCExecutionFactory
- Throws:
TranslatorException
-
createUpdateExecution
public JDBCUpdateExecution createUpdateExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Connection conn) throws TranslatorException
- Overrides:
createUpdateExecution
in classJDBCExecutionFactory
- Throws:
TranslatorException
-
getSQLConversionVisitor
public PhoenixSQLConversionVisitor getSQLConversionVisitor()
Description copied from class:JDBCExecutionFactory
Create theSQLConversionVisitor
that will perform translation. Typical custom JDBC connectors will not need to create custom conversion visitors, rather implementors should override existingJDBCExecutionFactory
methods.- Overrides:
getSQLConversionVisitor
in classJDBCExecutionFactory
- Returns:
- the
SQLConversionVisitor
-
bindValue
public void bindValue(PreparedStatement pstmt, Object param, Class<?> paramType, int i) throws SQLException
Description copied from class:JDBCExecutionFactory
Sets prepared statement parameter i with param. Performs special handling to translate dates using the database time zone and to translate biginteger, float, and char to JDBC safe objects.- Overrides:
bindValue
in classJDBCExecutionFactory
- Throws:
SQLException
-
supportsInsertWithQueryExpression
public boolean supportsInsertWithQueryExpression()
Description copied from class:ExecutionFactory
Support indicates that the connector can accept INSERTs with values specified by aSetQuery
orSelect
- Overrides:
supportsInsertWithQueryExpression
in classJDBCExecutionFactory
-
translateLiteralBoolean
public String translateLiteralBoolean(Boolean booleanValue)
Description copied from class:JDBCExecutionFactory
Subclasses should override this method to provide a different sql translation of the literal boolean value. By default, a boolean literal is represented as:'0'
or'1'
.- Overrides:
translateLiteralBoolean
in classJDBCExecutionFactory
- Parameters:
booleanValue
- Boolean value, never null- Returns:
- Translated string
-
translate
public List<?> translate(LanguageObject obj, ExecutionContext context)
Adding a specific workaround for just Pheonix and BigDecimal.- Overrides:
translate
in classJDBCExecutionFactory
- Returns:
- list of translated parts
-
translateLiteralDate
public String translateLiteralDate(Date dateValue)
It doesn't appear that the time component is needed, but for consistency with their documentation, we'll add it.- Overrides:
translateLiteralDate
in classJDBCExecutionFactory
- Parameters:
dateValue
- Date value, never null- Returns:
- Translated string
-
translateLiteralTime
public String translateLiteralTime(Time timeValue)
A date component is required, so create a new Timestamp instead- Overrides:
translateLiteralTime
in classJDBCExecutionFactory
- Parameters:
timeValue
- Time value, never null- Returns:
- Translated string
-
translateLiteralTimestamp
public String translateLiteralTimestamp(Timestamp timestampValue)
Description copied from class:JDBCExecutionFactory
Subclasses should override this method to provide a different sql translation of the literal timestamp value. By default, a timestamp literal is represented as:{ts '2002-12-31 23:59:59'}
. SeeJDBCExecutionFactory.getTimestampNanoPrecision()
to control the literal precision.- Overrides:
translateLiteralTimestamp
in classJDBCExecutionFactory
- Parameters:
timestampValue
- Timestamp value, never null- Returns:
- Translated string
-
retrieveValue
public Object retrieveValue(ResultSet results, int columnIndex, Class<?> expectedType) throws SQLException
The Phoenix driver has issues using a calendar object. it throws an npe on a null value and also has https://issues.apache.org/jira/browse/PHOENIX-869- Overrides:
retrieveValue
in classJDBCExecutionFactory
- Returns:
- the value
- Throws:
SQLException
-
createMetadataProcessor
protected JDBCMetadataProcessor createMetadataProcessor()
- Overrides:
createMetadataProcessor
in classJDBCExecutionFactory
- See Also:
JDBCExecutionFactory.getMetadataProcessor()
-
getRequiredLikeEscape
public Character getRequiredLikeEscape()
Description copied from class:ExecutionFactory
The required escape character or null if all are supported.- Overrides:
getRequiredLikeEscape
in classExecutionFactory<DataSource,Connection>
- Returns:
-
translateCommand
public List<?> translateCommand(Command command, ExecutionContext context)
Description copied from class:JDBCExecutionFactory
Return a List of translated parts (LanguageObject
s and Objects), or null if to rely on the default translation.- Overrides:
translateCommand
in classJDBCExecutionFactory
- Returns:
- a list of translated parts
-
translateLimit
public List<?> translateLimit(Limit limit, ExecutionContext context)
Description copied from class:JDBCExecutionFactory
Return a List of translated parts (LanguageObject
s and Objects), or null if to rely on the default translation.- Overrides:
translateLimit
in classJDBCExecutionFactory
- Returns:
- a list of translated parts
-
supportsRowLimit
public boolean supportsRowLimit()
Description copied from class:ExecutionFactory
Gets whether the connector can limit the number of rows returned by a query.- Overrides:
supportsRowLimit
in classExecutionFactory<DataSource,Connection>
-
supportsScalarSubqueryProjection
public boolean supportsScalarSubqueryProjection()
Description copied from class:ExecutionFactory
If a scalar subquery can be projected.- Overrides:
supportsScalarSubqueryProjection
in classExecutionFactory<DataSource,Connection>
- Returns:
-
supportsUpsert
public boolean supportsUpsert()
- Overrides:
supportsUpsert
in classExecutionFactory<DataSource,Connection>
- Returns:
- true if the source supports upsert
-
usesDatabaseVersion
protected boolean usesDatabaseVersion()
- Overrides:
usesDatabaseVersion
in classJDBCExecutionFactory
-
supportsRowOffset
public boolean supportsRowOffset()
Description copied from class:ExecutionFactory
Gets whether the connector supports a SQL clause (similar to the LIMIT with an offset) that can return result sets that start in the middle of the resulting rows returned by a query- Overrides:
supportsRowOffset
in classExecutionFactory<DataSource,Connection>
-
-