xtdb

eval2020 2024-12-16T20:16:06.911449Z

Was looking at the railroad-diagrams (very cool!) and was curious why the table-alias was not right after the table: from users for valid_time as of TIMESTAMP ? u1 instead of from users u1 for valid_time as of TIMESTAMP ? 🤔

seancorfield 2024-12-16T20:20:19.263659Z

Seems to match SQL Server: https://learn.microsoft.com/en-us/sql/relational-databases/tables/querying-data-in-a-system-versioned-temporal-table?view=sql-server-ver16

DECLARE @ADayAgo DATETIME2;
SET @ADayAgo = DATEADD(DAY, -1, SYSUTCDATETIME());

-- Comparison between two points in time for subset of rows
SELECT D_1_Ago.[DeptID],
    D.[DeptID],
    D_1_Ago.[DeptName],
    D.[DeptName],
    D_1_Ago.[ValidFrom],
    D.[ValidFrom],
    D_1_Ago.[ValidTo],
    D.[ValidTo]
FROM [dbo].[Department]
FOR SYSTEM_TIME AS OF @ADayAgo AS D_1_Ago
INNER JOIN [Department] AS D
    ON D_1_Ago.[DeptID] = [D].[DeptID]
        AND D_1_Ago.[DeptID] BETWEEN 1 AND 5;

👍 1
jarohen 2024-12-17T07:19:23.004809Z

yeah, this is one from the SQL spec I'm afraid, it's caught me out a good few times too 😅

jarohen 2024-12-17T07:21:57.052319Z

my guess at the intuition is that it's naming the filtered relation rather than the base table, i.e. "(table for valid time ...) as foo"

eval2020 2024-12-17T09:46:46.592799Z

legacy 🙂