ClickHouse / ClickHouse/ClickHouse

Support `SET TIME ZONE INTERVAL '±hh:mm' HOUR TO MINUTE` and `SET SESSION CHARACTERISTICS`

Open
#99,612 4 comments 0 reactions 0 assignees View on GitHub
comp-sql-syntax feature sql-compatibility st-discussion
Dominant language
C++
Stars
49.9k
Forks
9k
Avg merge
21h 32m
Merged PRs (30d)
515

Description

## Summary

Beyond the simple string form of `SET TIME ZONE` (e.g. `SET TIME ZONE 'UTC'`), several SQL-compatible clients and tools also emit timezone settings as interval offsets (`SET TIME ZONE INTERVAL '+05:30' HOUR TO MINUTE`) and use `SET SESSION CHARACTERISTICS` for session-level configuration. Neither is currently supported in ClickHouse. See the [PostgreSQL documentation on SET](https://www.postgresql.org/docs/current/sql-set.html) for reference.

## Current Behavior

```sql
SET TIME ZONE INTERVAL '+05:30' HOUR TO MINUTE;
-- Code: 62. DB::Exception: Syntax error

SET TIME ZONE LOCAL;
-- Code: 62. DB::Exception: Syntax error

SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE;
-- Code: 62. DB::Exception: Syntax error
```

## Expected Behavior

```sql
-- Set timezone by UTC offset interval:
SET TIME ZONE INTERVAL '+05:30' HOUR TO MINUTE;
SELECT timezone(); -- Returns e.g. '+05:30' or equivalent

SET TIME ZONE INTERVAL '-08:00' HOUR TO MINUTE;
SELECT timezone(); -- Returns '-08:00'

-- Reset to server default:
SET TIME ZONE LOCAL;
SELECT timezone(); -- Returns server's configured timezone

-- Session characteristics (parsed and silently accepted for compatibility):
SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ COMMITTED;
```

## Notes

- The interval form should map to the session timezone setting the same way the string form does.
- `SET TIME ZONE LOCAL` should reset to the server-configured timezone.
- `SET SESSION CHARACTERISTICS AS TRANSACTION ...` can initially be accepted and no-op'd for compatibility, since ClickHouse's transaction model is different.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.