Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declare null_value_pattern as regexp #3650

Merged
merged 1 commit into from
Mar 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/fluent/plugin/parser.rb
Expand Up @@ -89,7 +89,7 @@ class ParserError < StandardError; end
# : format[, timezone]

config_param :time_key, :string, default: nil
config_param :null_value_pattern, :string, default: nil
config_param :null_value_pattern, :regexp, default: nil
config_param :null_empty_string, :bool, default: false
config_param :estimate_current_event, :bool, default: true
config_param :keep_time_key, :bool, default: false
Expand All @@ -115,9 +115,8 @@ def configure(conf)
super

@time_parser = time_parser_create
@null_value_regexp = @null_value_pattern && Regexp.new(@null_value_pattern)
@type_converters = build_type_converters(@types)
@execute_convert_values = @type_converters || @null_value_regexp || @null_empty_string
@execute_convert_values = @type_converters || @null_value_pattern || @null_empty_string
@timeout_checker = if @timeout
class << self
alias_method :parse_orig, :parse
Expand Down Expand Up @@ -220,7 +219,7 @@ def convert_values(time, record)
return time, record
end

def string_like_null(value, null_empty_string = @null_empty_string, null_value_regexp = @null_value_regexp)
def string_like_null(value, null_empty_string = @null_empty_string, null_value_regexp = @null_value_pattern)
null_empty_string && value.empty? || null_value_regexp && string_safe_encoding(value){|s| null_value_regexp.match(s) }
end

Expand Down