Interface ExaMetadata
-
public interface ExaMetadataThis interface enables scripts to access metadata such as information about the database and the script.Furthermore, it provides related methods, e.g. to access connections and to import scripts.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ExaConnectionInformationgetConnection(String name)Get the details for a connection object with the given name.StringgetCurrentSchema()If the script is executed in the context of a selected (aka.StringgetCurrentUser()Get the name of the database user that was used to run the script.StringgetDatabaseName()Get the name of the database the script runs on.StringgetDatabaseVersion()Get the version of the database the script runs on.longgetInputColumnCount()Get the number of input columns.longgetInputColumnLength(int column)Length of the input column at the given index.StringgetInputColumnName(int column)Get the name of the input column at the given index.longgetInputColumnPrecision(int column)Get the precision of the input column at the given index.longgetInputColumnScale(int column)Get the scale of the input column at the given index.StringgetInputColumnSqlType(int column)Get the SQL data type of the input column at the given index.Class<?>getInputColumnType(int column)Get the Java data type of the input column at the given index.StringgetInputType()Get the type of the UDF script.BigIntegergetMemoryLimit()Get the memory limit for the JVM process that powers the script.longgetNodeCount()Get the number of data nodes of the database cluster running the script.longgetNodeId()Get ID of the cluster node the script runs on.longgetOutputColumnCount()Get the number of output columns.longgetOutputColumnLength(int column)Get the length of the output column at the given index.StringgetOutputColumnName(int column)Get the name of the output column at the given index.longgetOutputColumnPrecision(int column)Get the precision of the output column at the given index.longgetOutputColumnScale(int column)Get the scale of the column at the given index.StringgetOutputColumnSqlType(int column)Get the SQL data type of the output column at the given index.Class<?>getOutputColumnType(int column)Get the Java data type of the output column at the given index.StringgetOutputType()Get the type of output the script produces.StringgetScopeUser()Get the name of the database user who is the owner of the script.StringgetScriptCode()Get the content of the script.StringgetScriptLanguage()Get the name and version of the execution environment (aka.StringgetScriptName()Get the name of the database object as which the script is registered in the database.StringgetScriptSchema()Get the name of the database schema that is the parent database object of the script.StringgetSessionId()Get the database session this script runs in.longgetStatementId()Get the ID of the statement the script runs in.StringgetVmId()Get unique number that identifies the local Java VM.Class<?>importScript(String name)Dynamically loads the code from the specified script, compiles it, and returns an instance of the main script class.
-
-
-
Method Detail
-
getDatabaseName
String getDatabaseName()
Get the name of the database the script runs on.- Returns:
- name of the database
-
getDatabaseVersion
String getDatabaseVersion()
Get the version of the database the script runs on.- Returns:
- version of the database
-
getScriptLanguage
String getScriptLanguage()
Get the name and version of the execution environment (aka. "script language") the script runs on.- Returns:
- name and version of the script language, e.g. "Java 11"
-
getScriptName
String getScriptName()
Get the name of the database object as which the script is registered in the database.- Returns:
- name of the script
-
getScriptSchema
String getScriptSchema()
Get the name of the database schema that is the parent database object of the script.- Returns:
- name of the script schema
-
getCurrentUser
String getCurrentUser()
Get the name of the database user that was used to run the script.- Returns:
- name of the script user
-
getScopeUser
String getScopeUser()
Get the name of the database user who is the owner of the script.- Returns:
- name of the script scope user
-
getCurrentSchema
String getCurrentSchema()
If the script is executed in the context of a selected (aka. "open") schema, get the name of that schema.- Returns:
- name of the current open schema or
nullif no schema is selected
-
getScriptCode
String getScriptCode()
Get the content of the script.- Returns:
- text of the script
-
getSessionId
String getSessionId()
Get the database session this script runs in.- Returns:
- ID of the session in which the current statement is executed
-
getStatementId
long getStatementId()
Get the ID of the statement the script runs in.- Returns:
- ID of the current statement
-
getNodeCount
long getNodeCount()
Get the number of data nodes of the database cluster running the script.- Returns:
- number of nodes in the cluster
-
getNodeId
long getNodeId()
Get ID of the cluster node the script runs on.- Returns:
- ID of the node on which the current JVM is executed, starting with 0
-
getVmId
String getVmId()
Get unique number that identifies the local Java VM.The IDs of the virtual machines have no relation to each other.
- Returns:
- unique ID of the local JVM
-
getMemoryLimit
BigInteger getMemoryLimit()
Get the memory limit for the JVM process that powers the script.If this memory is exceeded, the database resource management will kill the JVM process.
- Returns:
- memory limit for the current JVM process in bytes.
-
getInputType
String getInputType()
Get the type of the UDF script.- Returns:
- input type of the script, either
SCALARorSET
-
getInputColumnCount
long getInputColumnCount()
Get the number of input columns.- Returns:
- number of input columns
-
getInputColumnName
String getInputColumnName(int column) throws ExaIterationException
Get the name of the input column at the given index.- Parameters:
column- index of the column, starting with 0- Returns:
- name of the specified input column
- Throws:
ExaIterationException- if used with an invalid iterator position or index
-
getInputColumnType
Class<?> getInputColumnType(int column) throws ExaIterationException
Get the Java data type of the input column at the given index.If this method for example returns
java.lang.String, you can access the data from this column usingExaIterator.getString(int).- Parameters:
column- index of the column, starting with 0- Returns:
- Java class used to represent data from the specified column
- Throws:
ExaIterationException- if used with an invalid iterator position or index
-
getInputColumnSqlType
String getInputColumnSqlType(int column) throws ExaIterationException
Get the SQL data type of the input column at the given index.This is a string in SQL syntax, e.g.
DECIMAL(18,0).- Parameters:
column- index of the column, starting with 0- Returns:
- sql type of the specified column
- Throws:
ExaIterationException- if used with an invalid iterator position or index
-
getInputColumnPrecision
long getInputColumnPrecision(int column) throws ExaIterationExceptionGet the precision of the input column at the given index.- Parameters:
column- index of the column, starting with 0- Returns:
- data type precision of the specified column, e.g. the precision of a
DECIMALdata type - Throws:
ExaIterationException- if used with an invalid iterator position or index
-
getInputColumnScale
long getInputColumnScale(int column) throws ExaIterationExceptionGet the scale of the input column at the given index.- Parameters:
column- index of the column, starting with 0- Returns:
- data type scale of the specified column, e.g. the scale of a
DECIMALdata type - Throws:
ExaIterationException- if used with an invalid iterator position or index
-
getInputColumnLength
long getInputColumnLength(int column) throws ExaIterationExceptionLength of the input column at the given index.- Parameters:
column- index of the column, starting with 0- Returns:
- data type length of the specified column, e.g. the length of a
VARCHARdata type. - Throws:
ExaIterationException- if used with an invalid iterator position or index
-
getOutputType
String getOutputType()
Get the type of output the script produces.- Returns:
- output type of the script, either
RETURNSorEMITS
-
getOutputColumnCount
long getOutputColumnCount()
Get the number of output columns.- Returns:
- number of output columns
-
getOutputColumnName
String getOutputColumnName(int column) throws ExaIterationException
Get the name of the output column at the given index.- Parameters:
column- index of the column, starting with 0- Returns:
- name of the specified output column
- Throws:
ExaIterationException- if used with an invalid iterator position or index
-
getOutputColumnType
Class<?> getOutputColumnType(int column) throws ExaIterationException
Get the Java data type of the output column at the given index.If this returns
java.lang.String, you can emit data for this column using aString.- Parameters:
column- index of the column, starting with 0- Returns:
- the java class used to represent data from the specified output column
- Throws:
ExaIterationException- if used with an invalid iterator position or index
-
getOutputColumnSqlType
String getOutputColumnSqlType(int column) throws ExaIterationException
Get the SQL data type of the output column at the given index.This is a string in SQL syntax, e.g.
DECIMAL(18,0).- Parameters:
column- index of the column, starting with 0- Returns:
- sql type of the specified output column
- Throws:
ExaIterationException- if used with an invalid iterator position or index
-
getOutputColumnPrecision
long getOutputColumnPrecision(int column) throws ExaIterationExceptionGet the precision of the output column at the given index.- Parameters:
column- index of the column, starting with 0- Returns:
- data type precision of the specified output column, e.g. the precision of a
DECIMALdata type - Throws:
ExaIterationException- if used with an invalid iterator position or index
-
getOutputColumnScale
long getOutputColumnScale(int column) throws ExaIterationExceptionGet the scale of the column at the given index.- Parameters:
column- index of the column, starting with 0- Returns:
- data type scale of the specified output column, e.g. the scale of a
DECIMALdata type - Throws:
ExaIterationException- if used with an invalid iterator position or index
-
getOutputColumnLength
long getOutputColumnLength(int column) throws ExaIterationExceptionGet the length of the output column at the given index.- Parameters:
column- index of the column, starting with 0- Returns:
- data type length of the specified column, e.g. the length of a
VARCHARdata type - Throws:
ExaIterationException- if used with an invalid iterator position or index
-
importScript
Class<?> importScript(String name) throws ExaCompilationException, ClassNotFoundException
Dynamically loads the code from the specified script, compiles it, and returns an instance of the main script class.You can use Java Reflection to work with this class.
Please note that there is a simple way to include other code using the keywords
%importand%jarin the script code (see user manual).- Parameters:
name- The name of the script to be imported (case-sensitive)- Returns:
- instance of the main script class of the imported script
- Throws:
ExaCompilationException- if the script cannot be compiled (e.g. because of syntax errors)ClassNotFoundException- if the script entry class is not found
-
getConnection
ExaConnectionInformation getConnection(String name) throws ExaConnectionAccessException
Get the details for a connection object with the given name.Access the information of a connection (created with
CREATE CONNECTION). The executing user must have the according privileges to access the script (see user manual).- Parameters:
name- name of the connection- Returns:
- an ExaConnectionInformation instance holding all information of the connection
- Throws:
ExaConnectionAccessException- if the connection object is not accessible (e.g. in cas of missing permissions)
-
-