Method for automatically analyzing non-standard date and time format data

CN118569245AInactive Publication Date: 2024-08-30成都虚谷伟业科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410885795.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-03
Publication Date
2024-08-30
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

使用上述方法②,Seatunnel能成功读取解析非标准日期时间格式的时间字符串数据,且成功输出数据到目的端,但是需要使用者自己编写对应的数据类型转换sql,这里有三个缺点:一是效率问题,每次遇见非标准格式的时间字符串时,都需要使用者去编写对应的转换sql;二是需要操作人员对Seatunnel技术有一定的了解,熟悉Seatunnel脚本的编写,通过这种方式来实现解析时间字符串数据时,则需要对提高操作人员的技术要求;三是现有市场上使用Seatunnel来实现数据同步功能的产品,一般为了降低使用者的使用难度,不会直接让操作人员编写Seatunnel脚本,会将Seatunnel的输入,输出等配置项在前端封装一下,通过让操作人员直接配置相关信息项实现数据的同步,来实现零代码开发数据同步的工作流

Benefits of technology

1、本发明中用户无需自己编写sql脚本对非标准日期时间格式的源数据进行格式转换,可直接使用Seatunnel 内部的时间类型去读取数据,系统会自动识别并解析源数据,提高了用户的便捷性和效率,且通过减少用户自己编写脚本的场景,减少了用户可能出现的错误,降低了错误率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118569245A
    Figure CN118569245A
Patent Text Reader

Abstract

The invention discloses a method for automatically analyzing non-standard date and time format data. The method comprises the following steps: S1, inputting source data; s2, identifying the source data, and extracting date and time type data; s3, analyzing and replacing the date and time type data; and S4, outputting, analyzing and replacing the time type data. According to the method, a user does not need to have professional Satunnel script writing knowledge, the technical threshold is lowered, more people can conveniently use Satunnel to collect data in a synchronous non-standard date and time format, and the technical threshold is lowered. Therefore, the user can more quickly realize the collection synchronization of the time character string data, and the interaction experience of the user is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of computer technology, and in particular to a method for automatically parsing data in non-standard date and time formats. Background Art

[0002] When using Seatunnel to collect and synchronize date and time type data, you need to parse the data into Seatunnel internal time type data and output it to the destination. There are two common methods for Seatunnel to process time type data: ① Directly use Seatunnel internal time type to read data, parse and output it to the destination. ② Use Seatunnel string type to read data, and then use Seatunnel SQL statement to use time type related functions to perform corresponding format conversion, converting the data type from string to Seatunnel internal time type.

[0003] When using the above method ①, Seatunnel can only parse date and time strings that conform to the ISO 8601 standard format when encountering a time string, and the general format is 'YYYY-MM-DDTHH:mm:ss', and does not support parsing of non-standard format strings. Using the above method ②, Seatunnel can successfully read and parse time string data in non-standard date and time formats, and successfully output the data to the destination, but the user needs to write the corresponding data type conversion SQL by himself, which has three disadvantages: First, the efficiency problem. Every time a non-standard time string is encountered, the user needs to write the corresponding conversion SQL; second, the operator needs to have a certain understanding of Seatunnel technology and be familiar with the writing of Seatunnel scripts. When implementing the parsing of time string data in this way, it is necessary to improve the technical requirements of the operator; third, the products on the market that use Seatunnel to implement data synchronization generally do not directly allow operators to write Seatunnel scripts in order to reduce the difficulty of use for users. Instead, Seatunnel's input, output and other configuration items will be encapsulated in the front end, and the operator is allowed to directly configure the relevant information items to synchronize data, thereby realizing a zero-code development data synchronization workflow. For products that implement data synchronization through zero-code development workflow, the above method ② cannot be used to parse time string data in non-standard date and time formats. Summary of the invention

[0004] In order to solve the above problems, the present invention provides a method for automatically parsing non-standard date and time format data, comprising the following steps: S1. inputting source data; S2. identifying the source data and extracting date and time type data; S3. parsing and replacing the date and time type data; S4. outputting the time type data after parsing and replacing.

[0005] Furthermore, the source data specifically includes: database data, API response data, and Kafka message data.

[0006] Furthermore, it also includes a definition step: S0. defining non-standard date and time format types and parsing rules.

[0007] Furthermore, the step S2 specifically includes the following sub-steps: S21. Using Seatunnel to identify the source data; S22. Extracting date and time type data; S23. Judging the source data and the extracted date and time type data.

[0008] Furthermore, the step S23 specifically includes: when the source data and the extracted date and time type data are not strings in a non-standard date and time format, executing step S4 after parsing the date and time type data according to Seatunnel; when the identified source data and the extracted date and time type data are strings in a non-standard date and time format, executing step S3.

[0009] Furthermore, the date and time type data parsing of Seatunnel is specifically as follows: identifying whether the string format is 'YYYY-MM-DDTHH:mm:ss', and directly outputting the string in this format when the string format is 'YYYY-MM-DDTHH:mm:ss'; and automatically parsing the string into date and time type data according to the defined parsing rules when the string format is not 'YYYY-MM-DDTHH:mm:ss'.

[0010] Furthermore, the parsing rule is specifically: parsing and converting the corresponding data into a Seatunnel internal time type; wherein the Seatunnel internal time type includes: date, timestamp.

[0011] The present invention provides a method for automatically parsing data in non-standard date and time formats, which has the following beneficial effects: 1. In the present invention, users do not need to write SQL scripts to convert the source data in non-standard date and time formats. They can directly use the time type inside Seatunnel to read the data. The system will automatically identify and parse the source data, which improves the convenience and efficiency of users. By reducing the scenarios where users need to write scripts themselves, it reduces the possible errors that users may make and reduces the error rate.

[0012] 2. In the present invention, users do not need to have professional Seatunnel scripting knowledge, which lowers the technical threshold and enables more people to conveniently use Seatunnel to collect and synchronize data in non-standard date and time formats, thus lowering the technical threshold. Users can more quickly collect and synchronize time string data, improving the user's interactive experience.

[0013] 3. By automatically identifying and parsing data in non-standard date and time formats, the present invention can be widely used in products with workflows that synchronize data with zero-code development, thereby solving the problem that such products cannot automatically identify and parse time string data in non-standard date and time formats. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the structures shown in these drawings without paying creative work.

[0015] Figure 1 The present invention provides a flow chart of the method. DETAILED DESCRIPTION

[0016] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0017] The following is a detailed description of the implementation method of the present invention in conjunction with the accompanying drawings. Only some embodiments are described, not all embodiments. For the purpose of clarity, representations and descriptions that are not related to the present invention are omitted in the drawings and descriptions.

[0018] In order to have a clearer understanding of the technical features, purposes and beneficial effects of the present invention, the technical solution of the present invention is now described in detail below. Obviously, the implementation cases described are part of the embodiments of the present invention, not all of the embodiments, and cannot be understood as limiting the scope of the implementation of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work belong to the protection scope of the present invention.

[0019] like Figure 1As shown, the present invention provides a method for automatically parsing data in non-standard date and time formats. By presetting the type of non-standard date and time formats and the corresponding parsing rules and mappings, when Seatunnel uses the time type to read data, it detects the date and time type corresponding to the time string data, maps and uses the corresponding parsing rules, and parses the data type of the time string data into the time type inside Seatunnel and outputs it to the specified target end, including the following steps: S1. Input source data; S2. Identify the source data and extract the date and time type data; S3. Parse and replace the date and time type data; S4. Output the parsed and replaced time type data. Wherein, the source data specifically includes: database data, API corresponding data, and Kafka message data.

[0020] The method also includes the following steps: S0. defining non-standard date and time format types and parsing rules. The parsing rules are as follows: parsing and converting the corresponding data into the Seatunnel internal time type.

[0021] Define non-standard time types and parsing rules, including defining non-standard date and time types and corresponding data parsing rules. Defining non-standard date and time types means presetting non-standard date and time types, such as 'YYYY / MM / DD', 'YYYY.MM.DD' and other formats. Defining date and time type data parsing rules means defining the parsing process and processing logic for parsing the time string data in non-standard date and time formats into the time type data inside Seatunnel. By identifying the corresponding date and time type, the corresponding parsing rules can be used to parse and process the source data to achieve data format conversion.

[0022] Step S2 specifically includes the following sub-steps: S21. Using Seatunnel to identify the source data; S22. Extracting date and time type data; S23. Judging the source data and the extracted date and time type data.

[0023] Date and time type data input refers to the process of using Seatunnel's time type to read source data when using Seatunnel to collect source data, and then entering the process of collecting, parsing, and synchronizing time type data. For example, in step S1, Seatunnel's timestamp type is used to collect source data with a value of '2000 / 12 / 12 10:10:10'. After data collection, data collection synchronization enters step S2.

[0024] Step S23 specifically includes: when the source data and the extracted date and time type data are not strings in a non-standard date and time format, executing step S4 after parsing the date and time type data according to Seatunnel; when the identified source data and the extracted date and time type data are strings in a non-standard date and time format, executing step S3.

[0025] Seatunnel's date and time type data parsing is specifically as follows: identify whether the string format is 'YYYY-MM-DDTHH:mm:ss'. When the string format is 'YYYY-MM-DDTHH:mm:ss', directly use this format for output; when the string format is not 'YYYY-MM-DDTHH:mm:ss', automatically parse the string into date and time type data according to the defined parsing rules.

[0026] The type of parsing date and time data specifies the data format of the input date and time data. When the source data is not a time string in a non-standard date and time format, the data goes through Seatunnel's own time data parsing process. When the source data is identified as a string and the format is a non-standard date and time format, the data enters the non-standard date and time format type parsing process. For example, when parsing the data input in step S1: '2000 / 12 / 12 10:10:10', if the data format is identified as a non-standard format 'YYYY / MM / DD hh:mi:ss', the data collection will synchronously enter step S3.

[0027] Applying the parsing rules for non-standard date and time format data means that when the type of the time string is identified, the corresponding parsing rules defined in step S0 are applied to parse the time string in the non-standard date and time format, and the corresponding data is parsed and converted into the internal time type of Seatunnel. This meets the requirement of outputting the time type data to the destination. For example, when the type of the time string obtained in step S2 is identified as 'YYYY / MM / DD hh:mi:ss', the parsing rules corresponding to this type in step S0 are applied to parse '2000 / 12 / 12 10:10:10' into the time type supported by Seatunnel, and output it to the specified destination.

[0028] The result output is to output the parsed time type data in the time type format of Seatunnel to the time type column of the specified destination. For example, the parsed time type data output by step S3 is received and output to the time type column of the specified destination. The internal time types of Seatunnel include: date and timestamp.

[0029] Example: When using seatunnel to synchronize Kafka message data to the database, there is a field data "2023 / 12 / 12 10:10:10" in the Kafka message. When using seatunnel's date and time type timestamp type to receive and match this data, the parsing will fail because "2023 / 12 / 12 10:10:10" is not a date and time string in the ISO 8601 standard format. When the method of automatically parsing non-standard date and time format data is used, when the source data "2023 / 12 / 1210:10:10" is input, it is recognized that the date and time string is not in the standard format, and the string data will be parsed and replaced with the data of the timestamp type.

[0030] In the present invention, the user does not need to understand the format of the time string in the source data. The program will automatically identify the type of non-standard date and time format, and automatically map and apply the corresponding parsing rules to parse the source data and convert the data type into the time type inside Seatunnel.

[0031] In the present invention, users do not need to write SQL scripts to convert the source data in non-standard date and time formats. They can directly use the time type inside Seatunnel to read the data. The system will automatically identify and parse the source data, which improves the convenience and efficiency of users. By reducing the scenarios where users need to write scripts themselves, it reduces the possible errors that users may make and reduces the error rate.

[0032] In the present invention, users do not need to have professional Seatunnel script writing knowledge, which reduces the technical threshold, allowing more people to conveniently use Seatunnel to collect and synchronize data in non-standard date and time formats, and reduces the technical threshold. Users can more quickly realize the collection and synchronization of time string data, which improves the user's interactive experience.

[0033] By automatically identifying and parsing data in non-standard date and time formats, the present invention can be widely used in products with workflows that synchronize data with zero-code development, solving the problem that such products cannot automatically identify and parse time string data in non-standard date and time formats.

[0034] The above is only a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the form disclosed herein, and should not be regarded as excluding other embodiments, but can be used in various other combinations, modifications and environments, and can be modified within the scope of the concept described herein through the above teachings or the technology or knowledge of the relevant field. The changes and modifications made by those skilled in the art shall not deviate from the spirit and scope of the present invention, and shall be within the scope of protection of the claims attached to the present invention.

Claims

1. A method for automatically parsing data in non-standard date and time formats, characterized in that: The following steps are involved: S1. Input source data; S2. Identify the source data and extract date and time type data; S3. Parse and replace date and time type data; S4. Output the time type data after parsing and replacement.

2. The method for automatically parsing data in non-standard date and time formats according to claim 1, characterized in that: The source data specifically includes: database data, API response data, and Kafka message data.

3. The method for automatically parsing data in non-standard date and time formats according to claim 1, characterized in that: The method also includes a definition step: S0. defining non-standard date and time format types and parsing rules.

4. The method for automatically parsing data in non-standard date and time formats according to claim 1, characterized in that: The S2 step specifically includes the following sub-steps: S21. Use Seatunnel to identify the source data; S22. Extract date and time type data; S23. Judge the source data and the extracted date and time type data.

5. The method for automatically parsing data in non-standard date and time formats according to claim 4, characterized in that: The step S23 specifically includes: When the source data and the extracted date and time type data are not strings in a non-standard date and time format, step S4 is performed after parsing the date and time type data according to Seatunnel; When the identified source data and the extracted date and time type data are character strings in a non-standard date and time format, step S3 is executed.

6. The method for automatically parsing data in non-standard date and time formats according to claim 5, characterized in that: The date and time type data parsing of Seatunnel is specifically as follows: identifying whether the string format is 'YYYY-MM-DDTHH:mm:ss', and directly using the format to output when the string format is 'YYYY-MM-DDTHH:mm:ss'; and automatically parsing the string into date and time type data according to the defined parsing rules when the string format is not 'YYYY-MM-DDTHH:mm:ss'.

7. The method for automatically parsing data in non-standard date and time formats according to claim 3, characterized in that: The parsing rule is specifically: parsing and converting the corresponding data into a Seatunnel internal time type; wherein the Seatunnel internal time type includes: date, timestamp.