Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
c0f5e33f
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c0f5e33f
编写于
7月 27, 2018
作者:
A
alesapin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add docs for URL table engine and url table function
上级
58ebe8d5
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
194 addition
and
0 deletion
+194
-0
docs/en/operations/table_engines/url.md
docs/en/operations/table_engines/url.md
+77
-0
docs/en/query_language/table_functions/url.md
docs/en/query_language/table_functions/url.md
+19
-0
docs/ru/operations/table_engines/url.md
docs/ru/operations/table_engines/url.md
+74
-0
docs/ru/query_language/table_functions/url.md
docs/ru/query_language/table_functions/url.md
+20
-0
docs/toc_en.yml
docs/toc_en.yml
+2
-0
docs/toc_ru.yml
docs/toc_ru.yml
+2
-0
未找到文件。
docs/en/operations/table_engines/url.md
0 → 100644
浏览文件 @
c0f5e33f
<a
name=
"table_engines-url"
></a>
# URL(URL, Format)
This data source operates with data on remote HTTP/HTTPS server. The engine is
similar to
[
`File`
](
./file.md#
)
.
## Usage in ClickHouse server
```
URL(URL, Format)
```
`Format`
should be supported for
`SELECT`
and/or
`INSERT`
. For the full list of
supported formats see
[
Formats
](
../../interfaces/formats.md#formats
)
.
`URL`
must match the format of Uniform Resource Locator. The specified
URL must address a server working with HTTP or HTTPS. The server shouldn't
require any additional HTTP-headers.
`INSERT`
and
`SELECT`
queries are transformed into
`POST`
and
`GET`
requests
respectively. For correct
`POST`
-requests handling the remote server should support
[
Chunked transfer encoding
](
https://ru.wikipedia.org/wiki/Chunked_transfer_encoding
)
.
**Example:**
**1.**
Create the
`url_engine_table`
table:
```
sql
CREATE
TABLE
url_engine_table
(
word
String
,
value
UInt64
)
ENGINE
=
URL
(
'http://127.0.0.1:12345/'
,
CSV
)
```
**2.**
Implement simple http-server using python3:
```
python3
from http.server import BaseHTTPRequestHandler, HTTPServer
class CSVHTTPServer(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-type', 'text/csv')
self.end_headers()
self.wfile.write(bytes('Hello,1\nWorld,2\n', "utf-8"))
if __name__ == "__main__":
server_address = ('127.0.0.1', 12345)
HTTPServer(server_address, CSVHTTPServer).serve_forever()
```
```
bash
python3 server.py
```
**3.**
Query the data:
```
sql
SELECT
*
FROM
url_engine_table
```
```
text
┌─word──┬─value─┐
│ Hello │ 1 │
│ World │ 2 │
└───────┴───────┘
```
## Details of implementation
-
Reads and writes can be parallel
-
Not supported:
-
`ALTER`
-
`SELECT ... SAMPLE`
-
Indices
-
Replication
docs/en/query_language/table_functions/url.md
0 → 100644
浏览文件 @
c0f5e33f
<a
name=
"table_functions-url"
></a>
# url
`url(URL, format, structure)`
- returns a table created from the
`URL`
with given
`format`
and
`structure`
.
URL - HTTP or HTTPS server address, which can accept
`GET`
and/or
`POST`
requests.
format -
[
format
](
../../interfaces/formats.md#formats
)
of the data.
structure - table structure in
`'UserID UInt64, Name String'`
format. Determines column names and types.
**Example**
```
sql
-- getting the first 3 lines of a table that contains columns of String and UInt32 type from HTTP-server which answers in CSV format.
SELECT
*
FROM
url
(
'http://127.0.0.1:12345/'
,
CSV
,
'column1 String, column2 UInt32'
)
LIMIT
3
```
docs/ru/operations/table_engines/url.md
0 → 100644
浏览文件 @
c0f5e33f
<a
name=
"table_engines-url"
></a>
# URL(URL, Format)
Управляет данными на удаленном HTTP/HTTPS сервере. Данный движок похож
на движок
[
`File`
](
./file.md#
)
.
## Использование движка в сервере ClickHouse
`Format`
должен быть таким, который ClickHouse, может использовать в запросах
`SELECT`
и, если есть необходимость,
`INSERT`
. Полный список поддерживаемых форматов смотрите в
разделе
[
Форматы
](
../../interfaces/formats.md#formats
)
.
`URL`
должен соответствовать структуре Uniform Resource Locator. По указанному URL должен находится сервер
работающий по протоколу HTTP или HTTPS. При этом не должно требоваться никаких
дополнительных заголовков для получения ответа от сервера.
Запросы
`INSERT`
и
`SELECT`
транслируются в
`POST`
и
`GET`
запросы
соответственно. Для обработки
`POST`
-запросов удаленный сервер должен поддерживать
[
Chunked transfer encoding
](
https://ru.wikipedia.org/wiki/Chunked_transfer_encoding
)
.
**Пример:**
**1.**
Создадим на сервере таблицу
`url_engine_table`
:
```
sql
CREATE
TABLE
url_engine_table
(
word
String
,
value
UInt64
)
ENGINE
=
URL
(
'http://127.0.0.1:12345/'
,
CSV
)
```
**2.**
Создадим простейший http-сервер стандартными средствами языка python3 и
запустим его:
```
python3
from http.server import BaseHTTPRequestHandler, HTTPServer
class CSVHTTPServer(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-type', 'text/csv')
self.end_headers()
self.wfile.write(bytes('Hello,1\nWorld,2\n', "utf-8"))
if __name__ == "__main__":
server_address = ('127.0.0.1', 12345)
HTTPServer(server_address, CSVHTTPServer).serve_forever()
```
```
bash
python3 server.py
```
**3.**
Запросим данные:
```
sql
SELECT
*
FROM
url_engine_table
```
```
text
┌─word──┬─value─┐
│ Hello │ 1 │
│ World │ 2 │
└───────┴───────┘
```
## Особенности использования
-
Поддерживается многопоточное чтение и запись.
-
Не поддерживается:
-
использование операций
`ALTER`
и
`SELECT...SAMPLE`
;
-
индексы;
-
репликация.
docs/ru/query_language/table_functions/url.md
0 → 100644
浏览文件 @
c0f5e33f
<a
name=
"table_functions-url"
></a>
# url
`url(URL, format, structure)`
- возвращает таблицу со столбцами, указанными в
`structure`
, созданную из данных находящихся по
`URL`
в формате
`format`
.
URL - адрес, по которому сервер принимает
`GET`
и/или
`POST`
запросы по
протоколу HTTP или HTTPS.
format -
[
формат
](
../../interfaces/formats.md#formats
)
данных.
structure - структура таблицы в форме
`'UserID UInt64, Name String'`
. Определяет имена и типы столбцов.
**Пример**
```
sql
-- получение 3-х строк таблицы, состоящей из двух колонк типа String и UInt32 от сервера, отдающего данные в формате CSV
SELECT
*
FROM
url
(
'http://127.0.0.1:12345/'
,
CSV
,
'column1 String, column2 UInt32'
)
LIMIT
3
```
docs/toc_en.yml
浏览文件 @
c0f5e33f
...
...
@@ -94,6 +94,7 @@ pages:
-
'
merge'
:
'
query_language/table_functions/merge.md'
-
'
numbers'
:
'
query_language/table_functions/numbers.md'
-
'
remote'
:
'
query_language/table_functions/remote.md'
-
'
url'
:
'
query_language/table_functions/url.md'
-
'
Dictionaries'
:
-
'
Introduction'
:
'
query_language/dicts/index.md'
-
'
External
dictionaries'
:
...
...
@@ -134,6 +135,7 @@ pages:
-
'
Null'
:
'
operations/table_engines/null.md'
-
'
Set'
:
'
operations/table_engines/set.md'
-
'
Join'
:
'
operations/table_engines/join.md'
-
'
URL'
:
'
operations/table_engines/url.md'
-
'
View'
:
'
operations/table_engines/view.md'
-
'
MaterializedView'
:
'
operations/table_engines/materializedview.md'
-
'
Integrations'
:
...
...
docs/toc_ru.yml
浏览文件 @
c0f5e33f
...
...
@@ -97,6 +97,7 @@ pages:
-
'
merge'
:
'
query_language/table_functions/merge.md'
-
'
numbers'
:
'
query_language/table_functions/numbers.md'
-
'
remote'
:
'
query_language/table_functions/remote.md'
-
'
url'
:
'
query_language/table_functions/url.md'
-
'
Словари'
:
-
'
Введение'
:
'
query_language/dicts/index.md'
-
'
Внешние
словари'
:
...
...
@@ -138,6 +139,7 @@ pages:
-
'
Null'
:
'
operations/table_engines/null.md'
-
'
Set'
:
'
operations/table_engines/set.md'
-
'
Join'
:
'
operations/table_engines/join.md'
-
'
URL'
:
'
operations/table_engines/url.md'
-
'
View'
:
'
operations/table_engines/view.md'
-
'
MaterializedView'
:
'
operations/table_engines/materializedview.md'
-
'
Интеграции'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录