Description
The td_fastexport
function extracts data from Teradata Vantage into
csv or R data.frame as specified by the user using FastExport protocol.
Usage Notes:
The function cannot be used to extract data from a volatile or global temporary table.
Do not use the function to fetch only a few rows, because it opens extra connections to the database, which is time consuming.
Only use this function to fetch many rows (at least 100,000 rows) so that the row-fetching performance gain exceeds the overhead of opening additional connections.
The function does not support all Teradata Database data types. For example, BLOB and CLOB are not supported.
For best results, do not use
group_by
orarrange
withtd_fastexport
function.The result set ordering behavior with
td_fastexport
may differ from the ordering withouttd_fastexport
. In particular, an object of class "tbl_teradata" containing an ordered analytic function may not produce an ordered result set. Usearrange
to guarantee result set order.
For additional information about fastexport protocol through teradatasql
driver, please refer the FastExport section of
terdatasql driver documentation.
Usage
td_fastexport(df, catch.errors.warnings = TRUE, export.to = "DF", ...)
Arguments
df |
Required Argument. |
catch.errors.warnings |
Optional Argument. |
export.to |
Optional Argument. |
... |
Optional Argument. |
Value
Function returns an object of class "FastExport" which is a
named list containing the following objects:
result : A R dataframe containing the data.
errors (only if "catch.errors.warnings" is set to TRUE):
If there are no errors, this contains NULL.
If there are errors, this contains a R dataframe containing the errors raised by fastexport protocol.
warnings (only if "catch.errors.warnings" is set to TRUE):
If there are no warnings, this contains NULL.
If there are errors, this contains a R dataframe containing the warnings raised by fastexport protocol.
Named list member can be referenced directly with the "$" operator.
See Also
td_fastload
Examples
# Note: Connection must be established before running td_fastexport().
# Load the required tables.
loadExampleData("time_series_example", "ocean_buoys_seq")
# Create object(s) of class "tbl_teradata".
df_seq <- tbl(con, "ocean_buoys_seq")
# Example 1: Export the data in a data.frame along with the errors and
# warnings, if any, while fetching the data.
val <- td_fastexport(df = df_seq)
# Print 10 rows of the fetched dataframe.
head(val$result, 10)
# Print the errors dataframe; NULL if there are no errors.
val$errors
# Print the warnings dataframe; NULL if there are no warnings.
val$warnings
# Example 2: Export the data without errors and warnings.
val <- td_fastexport(df = df_seq,
catch.errors.warnings = FALSE)
# Print the "FastExport" object.
print(val)
# Example 3: Export the data in a csv file, catch the errors and warnings,
# if any.
val <- td_fastexport(df = df_seq,
export.to = "CSV",
csv.file.name ="test.csv")
# Print the errors dataframe; NULL if there are no errors.
val$errors
# Print the warnings dataframe; NULL if there are no warnings.
val$warnings
# Example 4: Export the data in a csv file using the specified
# field.quote.char and field.separator.
td_fastexport(df = df_seq,
export.to = "CSV",
csv.file.name = "test.csv",
field.separator = ";",
field.quote.char = "'",
catch.errors.warnings = FALSE)