Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
378c6f7a
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,发现更多精彩内容 >>
提交
378c6f7a
编写于
3月 29, 2019
作者:
V
Vitaly Baranov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve the error message when format schema isn't set.
上级
08f85804
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
27 addition
and
23 deletion
+27
-23
dbms/src/Formats/CapnProtoRowInputStream.cpp
dbms/src/Formats/CapnProtoRowInputStream.cpp
+1
-1
dbms/src/Formats/FormatSchemaInfo.cpp
dbms/src/Formats/FormatSchemaInfo.cpp
+23
-15
dbms/src/Formats/FormatSchemaInfo.h
dbms/src/Formats/FormatSchemaInfo.h
+1
-5
dbms/src/Formats/ProtobufRowInputStream.cpp
dbms/src/Formats/ProtobufRowInputStream.cpp
+1
-1
dbms/src/Formats/ProtobufRowOutputStream.cpp
dbms/src/Formats/ProtobufRowOutputStream.cpp
+1
-1
未找到文件。
dbms/src/Formats/CapnProtoRowInputStream.cpp
浏览文件 @
378c6f7a
...
...
@@ -298,7 +298,7 @@ void registerInputFormatCapnProto(FormatFactory & factory)
[](
ReadBuffer
&
buf
,
const
Block
&
sample
,
const
Context
&
context
,
UInt64
max_block_size
,
const
FormatSettings
&
settings
)
{
return
std
::
make_shared
<
BlockInputStreamFromRowInputStream
>
(
std
::
make_shared
<
CapnProtoRowInputStream
>
(
buf
,
sample
,
FormatSchemaInfo
(
context
,
"
capnp
"
)),
std
::
make_shared
<
CapnProtoRowInputStream
>
(
buf
,
sample
,
FormatSchemaInfo
(
context
,
"
CapnProto
"
)),
sample
,
max_block_size
,
settings
);
...
...
dbms/src/Formats/FormatSchemaInfo.cpp
浏览文件 @
378c6f7a
...
...
@@ -11,20 +11,29 @@ namespace ErrorCodes
extern
const
int
BAD_ARGUMENTS
;
}
FormatSchemaInfo
::
FormatSchemaInfo
(
const
Context
&
context
,
const
String
&
schema_file_extension
,
bool
schema_required
)
namespace
{
String
format_schema
=
context
.
getSettingsRef
().
format_schema
.
toString
();
if
(
format_schema
.
empty
())
String
getFormatSchemaDefaultFileExtension
(
const
String
&
format
)
{
if
(
schema_required
)
{
throw
Exception
(
"Format schema requires the 'format_schema' setting to have the 'schema_file:message_name' format"
+
(
schema_file_extension
.
empty
()
?
""
:
", e.g. 'schema."
+
schema_file_extension
+
":Message'"
),
ErrorCodes
::
BAD_ARGUMENTS
);
}
return
;
if
(
format
==
"Protobuf"
)
return
"proto"
;
else
if
(
format
==
"CapnProto"
)
return
"capnp"
;
else
return
""
;
}
}
FormatSchemaInfo
::
FormatSchemaInfo
(
const
Context
&
context
,
const
String
&
format
)
{
String
format_schema
=
context
.
getSettingsRef
().
format_schema
.
toString
();
if
(
format_schema
.
empty
())
throw
Exception
(
"The format "
+
format
+
" requires a schema. The 'format_schema' setting should be set"
,
ErrorCodes
::
BAD_ARGUMENTS
);
String
default_file_extension
=
getFormatSchemaDefaultFileExtension
(
format
);
size_t
colon_pos
=
format_schema
.
find
(
':'
);
Poco
::
Path
path
;
...
...
@@ -33,12 +42,11 @@ FormatSchemaInfo::FormatSchemaInfo(const Context & context, const String & schem
{
throw
Exception
(
"Format schema requires the 'format_schema' setting to have the 'schema_file:message_name' format"
+
(
schema_file_extension
.
empty
()
?
""
:
", e.g. 'schema."
+
schema
_file_extension
+
":Message'"
)
+
". Got '"
+
format_schema
+
(
default_file_extension
.
empty
()
?
""
:
", e.g. 'schema."
+
default
_file_extension
+
":Message'"
)
+
". Got '"
+
format_schema
+
"'"
,
ErrorCodes
::
BAD_ARGUMENTS
);
}
is_null
=
false
;
message_name
=
format_schema
.
substr
(
colon_pos
+
1
);
auto
default_schema_directory
=
[
&
context
]()
...
...
@@ -51,8 +59,8 @@ FormatSchemaInfo::FormatSchemaInfo(const Context & context, const String & schem
return
context
.
hasGlobalContext
()
&&
(
context
.
getGlobalContext
().
getApplicationType
()
==
Context
::
ApplicationType
::
SERVER
);
};
if
(
path
.
getExtension
().
empty
()
&&
!
schema
_file_extension
.
empty
())
path
.
setExtension
(
schema
_file_extension
);
if
(
path
.
getExtension
().
empty
()
&&
!
default
_file_extension
.
empty
())
path
.
setExtension
(
default
_file_extension
);
if
(
path
.
isAbsolute
())
{
...
...
dbms/src/Formats/FormatSchemaInfo.h
浏览文件 @
378c6f7a
...
...
@@ -10,10 +10,7 @@ class Context;
class
FormatSchemaInfo
{
public:
FormatSchemaInfo
()
=
default
;
FormatSchemaInfo
(
const
Context
&
context
,
const
String
&
schema_file_extension
=
String
(),
bool
schema_required
=
true
);
bool
isNull
()
const
{
return
is_null
;
}
FormatSchemaInfo
(
const
Context
&
context
,
const
String
&
format
);
/// Returns path to the schema file.
const
String
&
schemaPath
()
const
{
return
schema_path
;
}
...
...
@@ -26,7 +23,6 @@ public:
const
String
&
messageName
()
const
{
return
message_name
;
}
private:
bool
is_null
=
true
;
String
schema_path
;
String
schema_directory
;
String
message_name
;
...
...
dbms/src/Formats/ProtobufRowInputStream.cpp
浏览文件 @
378c6f7a
...
...
@@ -75,7 +75,7 @@ void registerInputFormatProtobuf(FormatFactory & factory)
const
FormatSettings
&
settings
)
{
return
std
::
make_shared
<
BlockInputStreamFromRowInputStream
>
(
std
::
make_shared
<
ProtobufRowInputStream
>
(
buf
,
sample
,
FormatSchemaInfo
(
context
,
"
proto
"
)),
std
::
make_shared
<
ProtobufRowInputStream
>
(
buf
,
sample
,
FormatSchemaInfo
(
context
,
"
Protobuf
"
)),
sample
,
max_block_size
,
settings
);
});
}
...
...
dbms/src/Formats/ProtobufRowOutputStream.cpp
浏览文件 @
378c6f7a
...
...
@@ -38,7 +38,7 @@ void registerOutputFormatProtobuf(FormatFactory & factory)
"Protobuf"
,
[](
WriteBuffer
&
buf
,
const
Block
&
header
,
const
Context
&
context
,
const
FormatSettings
&
)
{
return
std
::
make_shared
<
BlockOutputStreamFromRowOutputStream
>
(
std
::
make_shared
<
ProtobufRowOutputStream
>
(
buf
,
header
,
FormatSchemaInfo
(
context
,
"
proto
"
)),
header
);
std
::
make_shared
<
ProtobufRowOutputStream
>
(
buf
,
header
,
FormatSchemaInfo
(
context
,
"
Protobuf
"
)),
header
);
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录