v.20.5New Feature

Add port function to extract port from URL

Add port function (to extract port from URL). #11120 (Azat Khuzhin).
Add port function to extract port number from a URL string.

Why it matters

The port function addresses the need to easily extract the port component from a URL within ClickHouse queries. This is valuable for users who perform URL parsing or need to analyze network-related data directly in SQL without external processing.

How to use it

Use the function by passing a URL string as an argument to port. The function returns the port number if present; otherwise, it returns an empty value or default. For example:

SELECT port('http://example.com:8080/path')


will return 8080.