Skip to content

[🍒][PLUGIN-1874] Add MariadbDBRecord Implementations #579

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

Conversation

psainics
Copy link
Contributor

🍒 [cherrypick]

Commits :

PR:


Add MariadbDBRecord Implementations

Jira : Plugin-1874

Description

Add class MariadbDBRecord extending MysqlDBRecord, to fix java.lang.ClassNotFoundException: Class io.cdap.plugin.db.DBRecord not found.


Tests

  • Tables used
CREATE TABLE benchmark_data_types_06 (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    age INT NOT NULL,
    birthdate DATE NOT NULL,
    year_of_birth YEAR NOT NULL,
    salary DECIMAL(10, 2) NOT NULL,
    is_active BOOLEAN NOT NULL,
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    profile_picture BLOB NOT NULL,
    description TEXT NOT NULL,
    rating FLOAT NOT NULL,
    json_data JSON NOT NULL,
    char_field CHAR(10) NOT NULL,
    tinyint_field TINYINT NOT NULL,
    smallint_field SMALLINT NOT NULL,
    mediumint_field MEDIUMINT NOT NULL,
    bigint_field BIGINT NOT NULL,
    double_field DOUBLE NOT NULL
);
  • Test Data
INSERT INTO benchmark_data_types_06 (name, age, birthdate, year_of_birth, salary, is_active, created_at, profile_picture, description, rating, json_data, char_field, tinyint_field, smallint_field, mediumint_field, bigint_field, double_field)
VALUES 
('Alice Johnson', 30, '1993-05-15', 1993, 55000.00, TRUE, '2023-10-01 12:00:00', 'binary data for Alice', 'Software Engineer', 4.5, '{"hobbies": ["reading", "gaming"]}', 'A123', 1, 100, 1000, 10000, 10.5),

('Bob Smith', 25, '1998-08-20', 1998, 45000.00, TRUE, '2023-10-01 12:00:00', 'binary data for Bob', 'Data Analyst', 4.0, '{"hobbies": ["sports", "music"]}', 'B456', 2, 200, 2000, 20000, 20.5),

('Charlie Brown', 35, '1988-12-30', 1988, 60000.00, FALSE, '2023-10-01 12:00:00', 'binary data for Charlie', 'Project Manager', 3.8, '{"hobbies": ["traveling", "cooking"]}', 'C789', 3, 300, 3000, 30000, 30.5),

('Diana Prince', 28, '1995-03-10', 1995, 52000.00, TRUE, '2023-10-01 12:00:00', 'binary data for Diana', 'Marketing Specialist', 4.2, '{"hobbies": ["photography", "writing"]}', 'D012', 4, 400, 4000, 40000, 40.5),

('Ethan Hunt', 40, '1983-07-25', 1983, 70000.00, TRUE, '2023-10-01 12:00:00', 'binary data for Ethan', 'Operations Manager', 4.8, '{"hobbies": ["fitness", "gaming"]}', 'E345', 5, 500, 5000, 50000, 50.5);

Test Case 1 (schema detection)

  • MySql
    image

  • Mariadb
    image

Test Case 2 (Write to file sink and diff to check difference)

image

tmp/sink % sha256sum 2025-04-14-16-21/part-r-00000 2025-04-14-16-22/part-r-00000
42d49bd3e2eecbd81fe0709c24e0e7672e3f99e81fa59713608aeb03c5847669  2025-04-14-16-21/part-r-00000
42d49bd3e2eecbd81fe0709c24e0e7672e3f99e81fa59713608aeb03c5847669  2025-04-14-16-22/part-r-00000
  • File Output
{
  "id": 1,
  "name": "Alice Johnson",
  "age": 30,
  "birthdate": 8535,
  "year_of_birth": 1993,
  "salary": 55000.00,
  "is_active": 1,
  "created_at": 1696161600000000,
  "profile_picture": [
    98,
    105,
    110,
    97,
    114,
    121,
    32,
    100,
    97,
    116,
    97,
    32,
    102,
    111,
    114,
    32,
    65,
    108,
    105,
    99,
    101
  ],
  "description": "Software Engineer",
  "rating": 4.5,
  "json_data": "{\"hobbies\": [\"reading\", \"gaming\"]}",
  "char_field": "A123",
  "tinyint_field": 1,
  "smallint_field": 100,
  "mediumint_field": 1000,
  "bigint_field": 10000,
  "double_field": 10.5
}
{
  "id": 2,
  "name": "Bob Smith",
  "age": 25,
  "birthdate": 10458,
  "year_of_birth": 1998,
  "salary": 45000.00,
  "is_active": 1,
  "created_at": 1696161600000000,
  "profile_picture": [
    98,
    105,
    110,
    97,
    114,
    121,
    32,
    100,
    97,
    116,
    97,
    32,
    102,
    111,
    114,
    32,
    66,
    111,
    98
  ],
  "description": "Data Analyst",
  "rating": 4.0,
  "json_data": "{\"hobbies\": [\"sports\", \"music\"]}",
  "char_field": "B456",
  "tinyint_field": 2,
  "smallint_field": 200,
  "mediumint_field": 2000,
  "bigint_field": 20000,
  "double_field": 20.5
}
{
  "id": 3,
  "name": "Charlie Brown",
  "age": 35,
  "birthdate": 6938,
  "year_of_birth": 1988,
  "salary": 60000.00,
  "is_active": 0,
  "created_at": 1696161600000000,
  "profile_picture": [
    98,
    105,
    110,
    97,
    114,
    121,
    32,
    100,
    97,
    116,
    97,
    32,
    102,
    111,
    114,
    32,
    67,
    104,
    97,
    114,
    108,
    105,
    101
  ],
  "description": "Project Manager",
  "rating": 3.799999952316284,
  "json_data": "{\"hobbies\": [\"traveling\", \"cooking\"]}",
  "char_field": "C789",
  "tinyint_field": 3,
  "smallint_field": 300,
  "mediumint_field": 3000,
  "bigint_field": 30000,
  "double_field": 30.5
}
{
  "id": 4,
  "name": "Diana Prince",
  "age": 28,
  "birthdate": 9199,
  "year_of_birth": 1995,
  "salary": 52000.00,
  "is_active": 1,
  "created_at": 1696161600000000,
  "profile_picture": [
    98,
    105,
    110,
    97,
    114,
    121,
    32,
    100,
    97,
    116,
    97,
    32,
    102,
    111,
    114,
    32,
    68,
    105,
    97,
    110,
    97
  ],
  "description": "Marketing Specialist",
  "rating": 4.199999809265137,
  "json_data": "{\"hobbies\": [\"photography\", \"writing\"]}",
  "char_field": "D012",
  "tinyint_field": 4,
  "smallint_field": 400,
  "mediumint_field": 4000,
  "bigint_field": 40000,
  "double_field": 40.5
}
{
  "id": 5,
  "name": "Ethan Hunt",
  "age": 40,
  "birthdate": 4953,
  "year_of_birth": 1983,
  "salary": 70000.00,
  "is_active": 1,
  "created_at": 1696161600000000,
  "profile_picture": [
    98,
    105,
    110,
    97,
    114,
    121,
    32,
    100,
    97,
    116,
    97,
    32,
    102,
    111,
    114,
    32,
    69,
    116,
    104,
    97,
    110
  ],
  "description": "Operations Manager",
  "rating": 4.800000190734863,
  "json_data": "{\"hobbies\": [\"fitness\", \"gaming\"]}",
  "char_field": "E345",
  "tinyint_field": 5,
  "smallint_field": 500,
  "mediumint_field": 5000,
  "bigint_field": 50000,
  "double_field": 50.5
}

Sanity on 6.10.x instance

Screenshot 2025-04-16 at 12 05 15 PM

@psainics psainics added the build label Apr 16, 2025
@psainics psainics self-assigned this Apr 16, 2025
@psainics psainics merged commit 2155e65 into data-integrations:release/1.11 Apr 16, 2025
7 of 17 checks passed
@psainics psainics deleted the cherry-pick/acd511cbf194305faa7e114bf78313e55a513288-r-1.11 branch April 16, 2025 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants