Skip to content

Conversation

@roshankumar0036singh
Copy link

Add Unit Tests for datatype.go

Type of Change

Description

This PR adds comprehensive unit tests for olake/utils/typeutils/datatype.go. The file previously lacked test coverage despite handling critical type detection and comparison logic.

During testing, a bug was identified and fixed in ExtractAndMapColumnType where unknown types were returning an empty string instead of types.Unknown.

Changes

  • Created olake/utils/typeutils/datatype_test.go:
    • TypeFromValue: Verified correct types.DataType return for primitives, pointers, slices, maps, and special types.
    • MaximumOnDataType: Verified Int64 and Timestamp comparisons.
    • detectTimestampPrecision: Verified precision detection (s, ms, us, ns).
    • ExtractAndMapColumnType: Verified SQL type mapping.
  • Fixed olake/utils/typeutils/datatype.go:
    • Updated ExtractAndMapColumnType to return types.Unknown for missing keys.

Verification

Screenshot 2026-01-09 005420
  • Automated Tests:
    • Environment: Verified in a golang:1.24-alpine Docker container.
    • Result: PASSED
    === RUN   TestTypeFromValue
    --- PASS: TestTypeFromValue (0.00s)
    === RUN   TestMaximumOnDataType
    --- PASS: TestMaximumOnDataType (0.00s)
    === RUN   TestDetectTimestampPrecision
    --- PASS: TestDetectTimestampPrecision (0.00s)
    === RUN   TestExtractAndMapColumnType
    --- PASS: TestExtractAndMapColumnType (0.00s)
    PASS
    ok      github.com/datazip-inc/olake/utils/typeutils    0.034s
    

@CLAassistant
Copy link

CLAassistant commented Jan 8, 2026

CLA assistant check
All committers have signed the CLA.

@roshankumar0036singh
Copy link
Author

@nayanj98 plz review it

@roshankumar0036singh roshankumar0036singh force-pushed the feat/datatype-tests branch 3 times, most recently from 21e22c0 to 3d5e6f1 Compare January 8, 2026 19:52
@roshankumar0036singh
Copy link
Author

@Akshay-datazip can you review the pr and close it if everything is ok and if not will make changes in it

@nayanj98
Copy link
Collaborator

@roshankumar0036singh please upload a video of you showing your work by running a sync using OLake. Until unless a proper video is uploaded a reviewer won’t be assigned. If you need further assistance related to video we can help you out.

@roshankumar0036singh
Copy link
Author

@nayanj98 this issue is regarding the test so i need to run all the test and record a video for it

@nayanj98
Copy link
Collaborator

@roshankumar0036singh What I would recommend is run a sync first using OLake. In this way you will have better ideas to build your unit test. What you can do is record a video by running the sync and you can upload it here. Below the video you can mention what all test cases can be included in unit test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add Unit Tests for datatype.go

3 participants