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

SQL API cloud native #150

Merged
merged 2 commits into from
Jun 14, 2021
Merged

SQL API cloud native #150

merged 2 commits into from
Jun 14, 2021

Conversation

alasarr
Copy link
Contributor

@alasarr alasarr commented Jun 14, 2021

This PR gives support to SQL API for CARTO cloud native (v3)

It also supports CARTO SQL API v1 and v2.

There is a breaking change on the API, since executeSQL parameters are now destructuring.

How to use:

Create a model

import { executeSQL } from '@carto/react-api';

const CONNECTION = 'bigquery';

export const getTotalArea = async ({ credentials, opts }) => {
  const query = `
  select SUM(do_area) as area from carto-do-public-data.carto.geography_aus_state_2016 
  `;

  return executeSQL({ credentials, connection: CONNECTION, query, opts });
};

Call from a view

import { getTotalArea } from '../../data/models/BigQueryModel';
 const credentials = useSelector((state) => state.carto.credentials);

  useEffect(() => {
    getTotalArea({ credentials }).then( d => {
      // whatever
    })

  }, [ credentials ]);

@alasarr alasarr requested a review from VictorVelarde June 14, 2021 12:44
@alasarr
Copy link
Contributor Author

alasarr commented Jun 14, 2021

@borja-munoz ☝️

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 935894892

  • 21 of 27 (77.78%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-1.05%) to 77.759%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/react-api/src/api/SQL.js 13 16 81.25%
packages/react-api/src/api/common.js 8 11 72.73%
Files with Coverage Reduction New Missed Lines %
packages/react-api/src/api/SQL.js 1 73.68%
Totals Coverage Status
Change from base Build 935458183: -1.05%
Covered Lines: 583
Relevant Lines: 713

💛 - Coveralls

Copy link
Contributor

@VictorVelarde VictorVelarde left a comment

Choose a reason for hiding this comment

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

LGTM. Just please add a note to CHANGELOG with a note like 'Add SQL API support for new v3 api'... and a BREAKING CHANGE note about the API for previous versions

@alasarr
Copy link
Contributor Author

alasarr commented Jun 14, 2021

LGTM. Just please add a note to CHANGELOG with a note like 'Add SQL API support for new v3 api'... and a BREAKING CHANGE note about the API for previous versions

I did but here

@alasarr alasarr merged commit 1e60f01 into master Jun 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants