ClickHouse / ClickHouse/ClickHouse
Request update to behaviour of `domain` and `toplevelDomain` functions for single labels.
- Dominant language
- C++
- Stars
- 49.9k
- Forks
- 9k
- Avg merge
- 21h 32m
- Merged PRs (30d)
- 515
Description
**Describe the unexpected behaviour**
[Documentation for the functions mentioned here ](https://github.com/ClickHouse/ClickHouse/blob/0b0b481825ba2e71074823d2d0bbce043e6e9b4f/docs/en/sql-reference/functions/url-functions.md)
Both the `domain` and `toplevelDomain` functions return an empty string if a single label is supplied e.g. `com`.
**How to reproduce**
* 21.3.17.2
* tested with clickhouse-client
```
:) select domain('com')
SELECT domain('com')
Query id: f235b335-c139-4ebb-856a-f2c797262c93
┌─domain('com')─┐
│ │
└───────────────┘
```
**Expected behavior**
A single label is technically a valid domain name. It would be nice if `.com`, `com` and `com.` all returned `com` as the TLD from this function. I realise the documentation makes clear the functions are not RFC compliant, but it would make them more useful for parsing domain names if the behaviour was updated. [QNAME Minimisation](https://datatracker.ietf.org/doc/html/rfc7816) use is increasing so single label queries from recursives to authoritatives are becoming more common.
**Documentation**
If the behaviour isn't updated, then perhaps this can just be documented more clearly - thanks!
Contributor guide
Assessment
This issue has not been assessed yet.