t_wの輪郭

Feedlyでフォローするボタン
Recursive QueriesWITHCTE
『How to Use a Common Table Expression (CTE) in SQL | Timescale』あれWITH RECURSIVE hoge AS MATERIALIZEDあれ

あれ

2024/9/29 16:35:00

こいつを実行するとな、

WITH RECURSIVE
	given AS NOT MATERIALIZED (
		SELECT ? as text
	),
	token AS MATERIALIZED (
		SELECT
			LENGTH(given.text) AS tail,
			0 as head,
			RIGHT(LEFT(given.text, tail-head), tail) AS chunk,
		FROM
			given
		
		UNION

		SELECT
			token.tail - 1 AS tail,
			0 as head,
			RIGHT(LEFT(token.chunk, tail-head), tail) AS chunk,
		FROM
			token
		WHERE
			tail > 0

	)
SELECT * FROM token;

こうなるんじゃ

[
  {
    tail: 4n,
    head: 0,
    chunk: "test",
  }, {
    tail: 3n,
    head: 0,
    chunk: "test",
  }, {
    tail: 2n,
    head: 0,
    chunk: "tes",
  }, {
    tail: 1n,
    head: 0,
    chunk: "te",
  }, {
    tail: 0n,
    head: 0,
    chunk: "t",
  }
]

素直にプログラミング言語でfor文をまわす方が簡単じゃな。

あれ

2024/9/29 16:09:00

SKKサーバーに文節機能つけたろwwwww

SQLで分かち書きしたろwwwww

WITH RECURSIVE hoge AS MATERIALIZED濫用部になってる。


「SQLで分かち書きしようとする人、全員バカです」になってる。大変すぎる。