%SQL.FDW.Wrapper.CsvWrapper
class %SQL.FDW.Wrapper.CsvWrapper extends %SQL.FDW.Wrapper.BaseWrapper
FOR INTERNAL USE - do not invoke directlyMethod Inventory
- %OnNew()
- close()
- createReaderObject()
- execute()
- get()
- getMetadata()
- getRequestObject()
- next()
- reset()
- validateServerConfig()
- validateTableConfig()
- validateTablesConfigArray()
Methods
method %OnNew(config As %DynamicObject) as %Status
Inherited description: All foreign data wrappers should define an %OnNew() method that will accept a JSON config object containing relevant
information for that wrapper to perform its intended behavior based on a given foreign server and foreign table. Upon
wrapper construction, the wrapper should be in a state that is sufficient to call execute() and to
provide metadata via the getMetadata() method. Note that the actual metadata does not need to be fetched
until getMetadata() is called, but that the wrapper should be prepared to do so upon execution without
any other interaction from the caller.
The wrapper config object conforms to the following format. The types listed are JSON types. For more information
about manipulating this object, see %Library.DynamicAbstractObject.
{
"server": {
"connection": string, corresponds to CONNECTION parameter the foreign server was created with.
"delimitedIds": boolean, corresponds to DELIMITEDIDS parameter the foreign server was created with.
"fdwName": string, name of the %SQL.FDW.Wrapper.BaseWrapper subclass that this server was intended to be used with.
"host": string, corresponds to HOST parameter the foreign server was created with.
"passthrough": boolean, corresponds to [ ENABLE | DISABLE ] PASSTHROUGH setting the foreign server was created with and specifies whether the server supports the PASSTHROUGH feature.
"pushdownType": string, if this wrapper is a subclass of %SQL.FDW.Wrapper.SqlWrapper, this setting corresponds to the PUSHDOWN setting the foreign server was created with.
"using": object, corresponds to the USING parameter the foreign server was created with, which can be used to specify any arbitrary table parameters your wrapper might need to function.
},
Note that this is a JSON array of tables involved in this wrapper. For example, this may be populated with multiple tables if pushdown logic decided to combine multiple tables into one pushdown unit.
"tables": [
{
"columns": array, corresponds to the COLUMNS parameter the foreign table was created with. This only applies to CSV foreign tables and is used to specify a custom header row.
"columnsTypes": array, names of datatypes corresponding to the indices in the columns array above. This only applies to CSV foreign tables.
"values": array, corresponds to the VALUES parameter the foreign table was created with (i.e. external column names.)
"query": string, corresponds to the QUERY parameter the foreign table was created with.
"table": string, corresponds to the TABLE parameter the foreign table was created with. Note that for foreign tables created under a foreign server that utilizes %SQL.FDW.Wrapper.CsvWrapper, this field contains the value entered for the FILE parameter upon creation of the foreign table.
"using": object, corresponds to the USING parameter the foreign table was created with, which can be used to specify any arbitrary table parameters your wrapper might need to function.
},
],
"sql": string, specifies the SQL text determined via internal pushdown logic. This logic is only performed during SQL query execution for foreign tables that belong to servers using wrappers that extend the %SQL.FDW.Wrapper.SqlWrapper class.
"sqlParameters": array, containing subarrays of the format [type, value] where each subarray corresponds positionally to a ? parameter in the config.sql parameter. The type is an integer corresponding to ODBC type numbers. For more information, see the %SQL.FDW.Wrapper.SqlWrapper class.
}
method close() as %Status
Close up the gateway objects/connection
method createReaderObject(config As %DynamicObject) as %Status
method execute() as %Status
No-op for CSV
method get(colIdx As %Integer) as %RawString
Inherited description: Get the value at column index columnIndex for the current row. This should match the value in
row(columnIndex). If the
method getMetadata() as %SQL.FDW.Metadata.ResultMetadata
Inherited description: Creates and returns an instance of %SQL.FDW.Metadata.ResultMetadata, which describes the result being
returned by this wrapper. For more information on the metadata object, see the %SQL.FDW.Metadata.ResultMetadata
class.
method getRequestObject(config As %DynamicObject) as %DynamicObject
Build and return request string used by Reader code for connecting to a database.
For a file, Server host = abs. path to directory, Table = filename+extension, port & user & pass are all N/A
method next() as %Boolean
Inherited description: The next() advances the wrapper to the next row. If such a row is found, this method returns 1. If
no additional row is found, this method returns 0. This method should always populate the multidimensional row
property with the current row's data in the structure of
row(columnIndex) = value.
method reset() as %Status
Inherited description: Resets the result set being looped over by the wrapper, effectively positioning the pointer before the first row again.
The wrapper API places no constraint on how this is done. For example, this method may require cleaning up all
resources and executing from the beginning; that is an implementation detail. Upon finishing reset(),
the wrapper should be as though execute() was just called the first time. In other words, the wrapper
should be prepared to loop over the result set that it projects, with the first next() call following
the reset returning the first row.
This method should return a %Status value. Consider using status code $$$ForeignDataWrapperError when reporting
custom error status messages.
classmethod validateServerConfig(serverConfig As %DynamicObject) as %Status
Inherited description: Given a %DynamicObject representing the server portion of a config object, validate that information
contained in the object is sufficient for this wrapper to act upon. For example, if a wrapper requires the server to
specify a "host" key, this method should validate that the serialized server information contains a relevant value:
This method should return a %Status value. Consider using status code $$$ForeignDataWrapperError when reporting
custom error status messages.
if serverConfig.%Get("host") = "" { RETURN $$$ERROR(...) }
classmethod validateTableConfig(tableConfig As %DynamicObject) as %Status
Inherited description: Given a %DynamicObject representing one table in the "tables" portion of a JSON config object,
validate that information contained in the object is sufficient for this wrapper to act upon. For example, if a
wrapper requires the tables to specify "table", this method should validate that the serialized table information
contains a relevant value.
This method should return a %Status value. Consider using status code $$$ForeignDataWrapperError when reporting
custom error status messages.
classmethod validateTablesConfigArray(tableConfigArray As %DynamicArray) as %Status
OVERRIDE METHOD - require size of 1
Inherited Members
Inherited Properties
Inherited Methods
- %AddToSaveSet()
- %ClassIsLatestVersion()
- %ClassName()
- %ConstructClone()
- %DispatchClassMethod()
- %DispatchGetModified()
- %DispatchGetProperty()
- %DispatchMethod()
- %DispatchSetModified()
- %DispatchSetMultidimProperty()
- %DispatchSetProperty()
- %Extends()
- %GetParameter()
- %IsA()
- %IsModified()
- %New()
- %NormalizeObject()
- %ObjectModified()
- %OnClose()
- %OriginalNamespace()
- %PackageName()
- %RemoveFromSaveSet()
- %SerializeObject()
- %SetModified()
- %ValidateObject()
- delimitIdentifier()