Skip to content

Latest commit

 

History

History
43 lines (35 loc) · 1.1 KB

README.md

File metadata and controls

43 lines (35 loc) · 1.1 KB

XPath UDF for ClickHouse

This is a simple UDF for ClickHouse that allows you to evaluate XPath expressions on XML data.

Examples

SELECT xpath('<product><name>Example</name></product>', '//product/name');
-- Output: Example

SELECT xpath('
    <product>
        <name>Example 1</name>
        <name>Example 2</name>
    </product>', '//product/name');
-- Output: Example 1
-- Only the first result is returned

SELECT xpath_to_array('
    <product>
        <name>Example 1</name>
        <name>Example 2</name>
    </product>', '//product/name');
-- Output: ['Example 1', 'Example 2']

Installation

# Clone the repository
git clone https://github.com/vlourme/xpath-clickhouse.git
cd xpath-clickhouse

# Build the project
cargo build --release

# Copy the releases to ClickHouse's user_scripts
cp target/release/xpath /var/lib/clickhouse/user_scripts
cp target/release/xpath_to_array /var/lib/clickhouse/user_scripts

# Copy the UDF declaration to ClickHouse root
cp xpath_function.xml /etc/clickhouse

Side notes