This week in Databend #25

Databend aimed to be an open source elastic and reliable cloud warehouse, it offers blazing fast query and combines elasticity, simplicity, low cost of the cloud, built to make the Data Cloud easy.

Big changes

Below is a list of some major changes that we don't want you to miss.

Features

Improvement

Build/Test/CI

Bug fixes

Experimental

A series of refactorings will be carried out at datavalues-dev branch to complete the migration. See RFC - new datavalues system design.

Tips

Let's learn a weekly tip from Databend.

Build/Test Databend with Dev container

In #3853 , we have introduced a development container to make it easy for contributors to build and test Databend.

build binary artifacts

./scripts/setup/run_docker.sh  make build

run test

./scripts/setup/run_docker.sh  make test

debug or get into dev container

./scripts/setup/run_docker.sh /bin/bash

Changlogs

You can check the changelogs of Databend nightly to learn about our latest developments.

Ecosystem/Upstream

From open source, for open source. Our team is also committed to contributing to the Rust ecosystem and upstream dependencies.

Meet Us

Please join the DatafuseLabs Community if you are interested in Databend.

We are looking forward to seeing you try our code. We have a strong team behind you to ensure a smooth experience in trying our code for your projects. If you are a hacker passionate about database internals, feel free to play with our code.

You can submit issues for any problems you find. We also highly appreciate any of your pull requests.

<think>嗯,用户问的是为什么SQLServer的DATEPART函数用ISO_WEEK参数时,2025-12-30会被识别为第一周。我需要先回忆一下ISO周的定义。ISO周的标准是,每年的第一周必须包含该年的至少四天,并且以周一作为一周的开始。比如,如果1月1日是周五,那么可能第一周从12月29日开始,这样2024年的最后几天可能属于2025年的第一周。接下来要查2025-12-30的具体日期情况。2025年12月30日是星期二,那年的1月1日是星期三。根据ISO标准,第一周需要包含该年的第一个星期四。2025年的第一个星期四是1月2日,所以第一周应该从2024年12月30日(周一)开始,到2025年1月5日结束。但是2025-12-30属于12月,这时候要看是否在下一年的第一周里。比如,如果2025年12月29日是周一,而12月30日是周二,这时候可能属于2026年的第一周吗?或者要看该周是否包含下一年的第一个星期四?这里可能需要具体计算。2025年的最后一天是12月31日,星期三。而2026年的第一个星期四是1月1日,因为2026年1月1日是星期四。所以2026年的第一周必须包含这个星期四,即1月1日。因此,第一周从2025年12月29日(周一)开始,到2026年1月4日结束。那么2025-12-30属于2026年的第一周,所以ISO_WEEK返回1,年份可能显示为2026?或者ISO_WEEK的年份和实际年份不同? 这时候可能需要用SQLServer的DATEPART和ISO_WEEK来验证。比如,执行SELECTDATEPART(ISO_WEEK,&#39;2025-12-30&#39;),返回1,而年份部分可能返回2026?或者年份部分还是2025,但周数为1?根据ISO标准,周数的年份可能和实际年份不同。例如,如果日期属于2025年,但周数属于2026年的第一周,那么DATEPART(ISO_YEAR,date)会返回2026,而ISO_WEEK返回1。因此,用户可能看到的结果是ISO周数为1,年份为2026,但日期本身是2025年12月30日。所以,总结起来,2025-12-30属于2026年ISO周的第一周,因为该周包含2026年的第一个星期四(1月1日),而该周从2025年12月29日开始。因此,DATEPART(ISO_WEEK,&#39;2025-12-30&#39;)返回1,而对应的ISO年份是2026。</think>### 为什么`2025-12-30`被识别为ISO周的第一周? #### 1. **ISO周的定义** - ISO 8601标准规定: 1. 每周从**周一**开始,到**周日**结束。 2. 每年的第一周必须包含**该年的第一个星期四**,且至少有4天属于该年[^1]。 3. 若某周的多数天数属于下一年,则它被归为**下一年**的第1周。 #### 2. **具体日期分析** - **2025年1月1日**是**星期三**,因此: - 第一个星期四为**2025年1月2日**。 - 根据ISO规则,2025年的第1周需包含该星期四,因此第1周从**2024年12月30日(周一)**开始,到**2025年1月5日(周日)**结束。 - **2025年12月30日**是**星期二**: - 该日期所在的周从**2025年12月29日(周一)**开始,到**2026年1月4日(周日)**结束。 - 该周包含**2026年的第一个星期四(2026年1月1日)**,因此被归为**2026年的第1周**。 #### 3. **SQL Server的验证** ```sql SELECT DATEPART(ISO_WEEK, &#39;2025-12-30&#39;) AS ISO_Week, -- 返回1 DATEPART(ISO_YEAR, &#39;2025-12-30&#39;) AS ISO_Year; -- 返回2026 ``` - **结果解释**: - `ISO_Week=1`:该日期属于2026年的第1周。 - `ISO_Year=2026`:ISO周年份与实际年份可能不同[^2]。 #### 4. **关键逻辑总结** - 日期`2025-12-30`所在的周(2025-12-29至2026-01-04)因包含2026年的第一个星期四(2026-01-01),被划入**2026年的第1周**。 - ISO周年份与自然年可能差异,例如2025年12月30日属于ISO年份2026[^3]。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值