Use this page to share code that you have developed for Trafodion and that could be useful for others. This could include, but is not restricted to:
- UDFs
- Stored Procedures
- Scripts to manage a Trafodion instance
- SQL queries to query Trafodion metadata
If the code is just a few lines, you could list it here. If it's multiple files, you could publish it in github and put a short description and a link here.
Also, please consider adding a license to your code in github, for example you can add an Apache license, so it is clear how your code can be used.
Stored Procedures
Scalar UDFs
Using Regular Expression in SQL (在SQL中使用正则表达式)
This demo UDF aims to provide an example about how to write a scalar UDF, instead of providing a production-level UDF. But one can start with it to enhance it to be more useful.
Standard SQL cannot do some complex query against a string. Like to filter out a valid phone number, a valid IP address or an email address. Regular Expression is a powerful tool to do this. This demo shows you how to write a UDF to enhance/extend Trafodion to support RegExp to do some more complex queries.
The source code can be downloaded from : https://github.com/traflm/trafodion-repos/tree/master/scalar-udf
Simulate to_char Oracle function
This demo will simulate the to_char function from Oracle.
The source code can be downloaded from: https://github.com/traflm/trafodion-repos/blob/master/scalar-udf/to_date.c
Table-Mapping UDFs
Reading Kafka Events
This UDF can read a topic from Apache Kafka. It is a basic serial Kafka consumer.
The source code can be downloaded from https://github.com/esgyn/code-examples/blob/master/src/main/java/org/trafodion/examples/udrs/udfs/table_valued/KafkaConsumerSerial
Group Concatenation
This UDF groups rows by one column and concatenates the values of one column occurring in the group, similar to the GROUP_CONCAT function in MySQL. It behaves like an aggregate or sequence function, but rather than computing min or max, etc. it computes a concatenation of the values in the group.
The source code can be downloaded from https://github.com/esgyn/code-examples/tree/master/src/main/java/org/trafodion/examples/udrs/udfs/table_valued/group_concat
Manageability
Tools
SQL Scripts and Queries
Miscellaneous