Skip to content

(feat) more data types#5

Draft
teetangh wants to merge 1 commit into
mainfrom
more-looker-data-types
Draft

(feat) more data types#5
teetangh wants to merge 1 commit into
mainfrom
more-looker-data-types

Conversation

@teetangh
Copy link
Copy Markdown
Contributor

@teetangh teetangh commented May 7, 2025

No description provided.

…entions, improving handling of arrays and nested objects, and ensuring accurate data representation in Looker Studio.
@teetangh teetangh self-assigned this May 7, 2025
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @teetangh, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request enhances the data type handling within the getSchema function of the columnar connector. It introduces heuristic type refinement based on field names, aiming to provide more accurate and specific Looker Studio types. The changes include logic to infer types like PERCENT, DURATION, CURRENCY, DATETIME, GEO, and URL based on naming conventions. Additionally, the code now converts field names to lowercase for case-insensitive matching during type refinement.

Highlights

  • Type Refinement: Implements heuristic type refinement based on field names to infer more specific Looker Studio types (e.g., PERCENT, DURATION, CURRENCY, DATETIME, GEO, URL).
  • Case-Insensitive Matching: Converts field names to lowercase for case-insensitive matching during type refinement.
  • Array Handling: Arrays are represented as a single STRING field.

Changelog

  • src/columnar/connector.gs
    • Added logic to convert field names to lowercase for case-insensitive matching.
    • Implemented heuristic type refinement for NUMBER fields to infer PERCENT, DURATION, and CURRENCY types based on field name.
    • Implemented heuristic type refinement for STRING fields to infer DATETIME, GEO, and URL types based on field name.
    • Modified the semantics object to include isReaggregatable for METRIC types.
    • Updated logging to include concept type for added fields.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A string, a number, a date,
In Looker's realm, we elevate.
By names they're known,
Their types are shown,
A richer view, we create.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request introduces heuristic type refinement based on field names, which enhances the schema inference for Looker Studio. This is a valuable addition, but there are areas where the logic can be improved for clarity and maintainability.

Summary of Findings

  • Type refinement heuristics: The heuristic type refinement logic is complex and could benefit from being broken down into smaller, more manageable functions. This would improve readability and testability.
  • Logging consistency: The logging statements within the type refinement logic are verbose. Consider consolidating these into a single, more informative log message per refinement.
  • Potential for false positives: The heuristic type refinement relies on simple string matching, which may lead to false positives. Consider adding more robust checks or allowing users to override the inferred types.

Merge Readiness

The changes introduce valuable heuristic type refinement. However, the complexity of the refinement logic and the potential for false positives warrant careful consideration. I recommend addressing the identified issues before merging to ensure the reliability and maintainability of the code. I am unable to approve this pull request, and recommend that others review and approve this code before merging.

Comment thread src/columnar/connector.gs
Comment on lines +824 to +826
if (lowerFieldName.includes('percent') || lowerFieldName.includes('rate') || lowerFieldName.includes('%')) {
lookerType = 'PERCENT';
Logger.log('Refined type for [%s] to PERCENT based on name.', fieldName);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider extracting this conditional logic into a separate function for better readability and testability. For example, isPercentField(lowerFieldName).

            if (isPercentField(lowerFieldName)) {
              lookerType = 'PERCENT';
              Logger.log('Refined type for [%s] to PERCENT based on name.', fieldName);
            }

Comment thread src/columnar/connector.gs
Comment on lines +827 to +829
} else if (lowerFieldName.includes('duration') || lowerFieldName.includes('_sec') || lowerFieldName.endsWith('seconds')) {
lookerType = 'DURATION';
Logger.log('Refined type for [%s] to DURATION based on name.', fieldName);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to the above, extract this conditional logic into a separate function, e.g., isDurationField(lowerFieldName).

            if (isDurationField(lowerFieldName)) {
              lookerType = 'DURATION';
               Logger.log('Refined type for [%s] to DURATION based on name.', fieldName);
            }

Comment thread src/columnar/connector.gs
Comment on lines +830 to +832
} else if (lowerFieldName.includes('amount') || lowerFieldName.includes('price') || lowerFieldName.includes('cost') || lowerFieldName.includes('revenue') || lowerFieldName.includes('salary') || lowerFieldName.includes('currency') || lowerFieldName.includes('$') || lowerFieldName.includes('€') || lowerFieldName.includes('£') || lowerFieldName.includes('¥')) {
lookerType = 'CURRENCY';
Logger.log('Refined type for [%s] to CURRENCY based on name.', fieldName);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Extract this conditional logic into a separate function, e.g., isCurrencyField(lowerFieldName).

            if (isCurrencyField(lowerFieldName)) {
              lookerType = 'CURRENCY';
              Logger.log('Refined type for [%s] to CURRENCY based on name.', fieldName);
            }

Comment thread src/columnar/connector.gs
Comment on lines +837 to +840
if (lowerFieldName.includes('date') || lowerFieldName.includes('time') || lowerFieldName.includes('timestamp') || lowerFieldName.match(/_dt$|_ts$/) || lowerFieldName.startsWith('dt_') || lowerFieldName.startsWith('ts_') ) {
// Use DATETIME as it's more general. Looker can format it.
lookerType = 'DATETIME';
Logger.log('Refined type for [%s] to DATETIME based on name.', fieldName);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Extract this conditional logic into a separate function, e.g., isDateTimeField(lowerFieldName).

             if (isDateTimeField(lowerFieldName)) {
                // Use DATETIME as it's more general. Looker can format it.
                lookerType = 'DATETIME';
                Logger.log('Refined type for [%s] to DATETIME based on name.', fieldName);
            }

Comment thread src/columnar/connector.gs
Comment on lines +841 to +843
} else if (lowerFieldName.includes('country') || lowerFieldName.includes('city') || lowerFieldName.includes('region') || lowerFieldName.includes('state') || lowerFieldName.includes('zip') || lowerFieldName.includes('postal') || lowerFieldName.includes('latitude') || lowerFieldName.includes('longitude') || lowerFieldName.includes('lat') || lowerFieldName.includes('lon') || lowerFieldName.match(/_geo$|_location$/)) {
lookerType = 'GEO';
Logger.log('Refined type for [%s] to GEO based on name.', fieldName);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Extract this conditional logic into a separate function, e.g., isGeoField(lowerFieldName).

            if (isGeoField(lowerFieldName)) {
              lookerType = 'GEO';
              Logger.log('Refined type for [%s] to GEO based on name.', fieldName);
            }

Comment thread src/columnar/connector.gs
Comment on lines +844 to +846
} else if (lowerFieldName.includes('url') || lowerFieldName.includes('link') || lowerFieldName.includes('website') || lowerFieldName.startsWith('http')) {
lookerType = 'URL';
Logger.log('Refined type for [%s] to URL based on name.', fieldName);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Extract this conditional logic into a separate function, e.g., isURLField(lowerFieldName).

            if (isURLField(lowerFieldName)) {
              lookerType = 'URL';
               Logger.log('Refined type for [%s] to URL based on name.', fieldName);
            }

@teetangh teetangh added bug Something isn't working invalid This doesn't seem right labels May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant