R language support for Apache Texera, enabling data processing workflows using R code.
R Installation (version 4.5.2)
- Download from: https://www.r-project.org/
- Other R versions may work but have not been tested
Required R packages (install these specific versions):
# Install tested versions
install.packages("remotes")
remotes::install_version("arrow", version = "14.0.2.1")
remotes::install_version("coro", version = "1.1.0")
remotes::install_version("aws.s3", version = "0.3.22")# Install from GitHub
pip install git+https://github.com/Texera/texera-rudf.git
# Development install
git clone https://github.com/Texera/texera-rudf.git
cd texera-rudf
pip install -e .The plugin provides two APIs for processing data in Texera workflows:
Version 0.2.0 provides UI parameter SDK v1 for Texera's R UDF and 1-out R UDF operators. Declare inputs in the script, then enter their values in Texera's properties panel:
count <- UiParameter("count", AttributeType$INT)$value
function(table, port) {
head(table, count)
}The SDK supports string, integer, long, double, boolean, and timestamp values, plus string parameters naming a model or dataset version. Long values require the R package bit64; the minimum signed 64-bit value is reserved for NA and cannot be a parameter value. Boolean text follows the Python SDK: true/false or numeric text, with nonzero interpreted as true.
Long values outside the supported range are rejected, including when bit64 would clamp them. Hexadecimal text is rejected for double and boolean parameters. Timestamps accept YYYY-MM-DD alone or with hour, minute, or second precision, optionally followed by Z or a numeric timezone offset such as +02:00.
Texera supplies the metadata and supported type/resource mappings. The plugin owns native R conversion and evaluates every parameterized script in its own environment. Existing scripts without parameters retain their execution path. The SDK's R source is packaged with the Python wheel; callers do not need to source an extra file.
Source Operator:
library(coro)
coro::generator(function() {
yield(list(col1 = "Hello World!", col2 = 1.0, col3 = TRUE))
})UDF Operator:
library(coro)
coro::generator(function(tuple, port) {
tuple$col4 <- tuple$col2 * 2
yield(tuple)
})Source Operator:
function() {
df <- data.frame(
col1 = "Hello World!",
col2 = 1.0,
col3 = TRUE
)
return(df)
}UDF Operator:
function(table, port) {
table$col4 <- table$col2 * 2
return(table)
}Handle large binary objects (images, files, etc.) via S3-compatible storage:
Writing Large Binary:
library(coro)
coro::generator(function() {
# Create a new large binary object
lb <- largebinary()
# Write data to it
stream <- LargeBinaryOutputStream(lb)
stream$write(charToRaw("Hello, Large Binary World!"))
stream$close()
yield(list(file_content = lb))
})Reading Large Binary:
library(coro)
coro::generator(function(tuple, port) {
# Read from large binary object
stream <- LargeBinaryInputStream(tuple$file_content)
data <- stream$read()
stream$close()
# Convert raw bytes to string
content <- rawToChar(data)
tuple$content_text <- content
yield(tuple)
})- UI Parameters: Typed inputs shared with Texera's properties panel
- Tuple API: Row-by-row processing with R generators
- Table API: Batch processing with R dataframes
- Apache Arrow: Efficient data transfer between Python and R
- Large Binary Support: Handle large objects via S3-compatible storage
This plugin has been tested and verified to work with the following versions:
Python Environment:
- Python: 3.10, 3.11, 3.12
- rpy2: 3.5.11
- rpy2-arrow: 0.0.8
R Environment:
- R: 4.5.2
- arrow: 14.0.2.1
- coro: 1.1.0
- aws.s3: 0.3.22
Other versions may work but have not been tested and are not guaranteed to be compatible.
Licensed under the MIT License. See LICENSE for details.
Contributions are welcome! To contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Issues: https://github.com/Texera/texera-rudf/issues
- Apache Texera: https://github.com/apache/texera
- rpy2: https://github.com/rpy2/rpy2