Teradata Package for R Function Reference | 17.00 - td_fastexport - Teradata Package for R - Look here for syntax, methods and examples for the functions included in the Teradata Package for R.

Teradata® Package for R Function Reference

Product
Teradata Package for R
Release Number
17.00
Published
July 2021
Language
English (United States)
Last Update
2023-08-08
dita:id
B700-4007
NMT
no
Product Category
Teradata Vantage
FastExport to extract data

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:

  1. The function cannot be used to extract data from a volatile or global temporary table.

  2. Do not use the function to fetch only a few rows, because it opens extra connections to the database, which is time consuming.

  3. 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.

  4. The function does not support all Teradata Database data types. For example, BLOB and CLOB are not supported.

  5. For best results, do not use group_by or arrange with td_fastexport function.

  6. The result set ordering behavior with td_fastexport may differ from the ordering without td_fastexport. In particular, an object of class "tbl_teradata" containing an ordered analytic function may not produce an ordered result set. Use arrange 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.
Specifies the tbl_teradata containing the data to be extracted.
Types: tbl_teradata

catch.errors.warnings

Optional Argument.
Specifies whether to catch errors and warnings (if any) raised by fastexport protocol while converting tbl_teradata to R dataframe.
Default Value: TRUE
Types: logical

export.to

Optional Argument.
Specifies whether to extract data to a CSV or a R data frame.
Permitted Values: "CSV", "DF"
Default Value: "DF"
Types: String

...

Optional Argument.
Specifies additional arguments required for future enhancements.

Value

Function returns an object of class "FastExport" which is a named list containing the following objects:

  1. result : A R dataframe containing the data.

  2. errors (only if "catch.errors.warnings" is set to TRUE):

    1. If there are no errors, this contains NULL.

    2. If there are errors, this contains a R dataframe containing the errors raised by fastexport protocol.

  3. warnings (only if "catch.errors.warnings" is set to TRUE):

    1. If there are no warnings, this contains NULL.

    2. 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)