Skip to content

Commit a4bc712

Browse files
authored
[BUG] - Hubspot Handler - CRUD operations (#11874)
1 parent 01a6b37 commit a4bc712

2 files changed

Lines changed: 430 additions & 138 deletions

File tree

mindsdb/integrations/handlers/hubspot_handler/README.md

Lines changed: 16 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ HubSpot handler for MindsDB provides interfaces to connect to HubSpot via APIs a
77
## Table of Contents
88

99
- [HubSpot Handler](#hubspot-handler)
10+
- [Table of Contents](#table-of-contents)
1011
- [About HubSpot](#about-hubspot)
1112
- [Installation](#installation)
1213
- [Authentication](#authentication)
@@ -96,6 +97,11 @@ The handler provides comprehensive data catalog capabilities:
9697
| `contacts` | Individual contact records | id, email, firstname, lastname | SELECT, INSERT, UPDATE, DELETE |
9798
| `deals` | Sales opportunity records | id, dealname, amount, stage | SELECT, INSERT, UPDATE, DELETE |
9899

100+
**Important Notes on Field Values:**
101+
- **Industry codes**: HubSpot uses predefined industry values (e.g., `COMPUTER_SOFTWARE`, `BIOTECHNOLOGY`, `FINANCIAL_SERVICES`). See [HubSpot's industry list](https://knowledge.hubspot.com/properties/hubspots-default-company-properties#industry) for all valid options.
102+
- **Deal stages**: Each HubSpot account has custom pipeline stages. Use the stage IDs from your account (e.g., `presentationscheduled`, `closedwon`, `closedlost`, or numeric IDs like `110382973`).
103+
- **Email validation**: Contact email addresses must be valid email formats (e.g., `user@example.com`).
104+
99105
## Example Usage
100106

101107
### Basic Connection
@@ -126,13 +132,6 @@ PARAMETERS = {
126132
SHOW TABLES FROM hubspot_datasource;
127133
```
128134

129-
**Get Table Schema:**
130-
```sql
131-
DESCRIBE hubspot_datasource.companies;
132-
DESCRIBE hubspot_datasource.contacts;
133-
DESCRIBE hubspot_datasource.deals;
134-
```
135-
136135
**Get Detailed Column Information:**
137136
```sql
138137
SELECT * FROM information_schema.columns
@@ -154,59 +153,29 @@ SELECT * FROM hubspot_datasource.contacts LIMIT 10;
154153
SELECT * FROM hubspot_datasource.deals LIMIT 10;
155154
```
156155

157-
**Advanced Filtering and Analytics:**
158-
```sql
159-
-- Companies by industry and location
160-
SELECT name, industry, city, state
161-
FROM hubspot_datasource.companies
162-
WHERE industry IN ('Technology', 'Healthcare')
163-
AND city = 'San Francisco'
164-
ORDER BY name;
165-
166-
-- Contact engagement analysis
167-
SELECT
168-
company,
169-
COUNT(*) as contact_count,
170-
STRING_AGG(email, ', ') as emails
171-
FROM hubspot_datasource.contacts
172-
WHERE company IS NOT NULL
173-
GROUP BY company
174-
ORDER BY contact_count DESC;
175-
176-
-- Sales pipeline analysis
177-
SELECT
178-
dealstage,
179-
COUNT(*) as deal_count,
180-
SUM(CAST(amount AS DECIMAL)) as total_value,
181-
AVG(CAST(amount AS DECIMAL)) as avg_deal_size
182-
FROM hubspot_datasource.deals
183-
WHERE amount IS NOT NULL
184-
GROUP BY dealstage
185-
ORDER BY total_value DESC;
186-
```
187156

188157
### Data Manipulation
189158

190159
**Creating Records:**
191160
```sql
192161
-- Create new company
193162
INSERT INTO hubspot_datasource.companies (name, domain, industry, city, state)
194-
VALUES ('Acme Corp', 'acme.com', 'Technology', 'New York', 'NY');
163+
VALUES ('Acme Corp', 'acme.com', 'COMPUTER_SOFTWARE', 'New York', 'NY');
195164

196165
-- Create new contact
197-
INSERT INTO hubspot_datasource.contacts (email, firstname, lastname, company, phone)
198-
VALUES ('john.doe@acme.com', 'John', 'Doe', 'Acme Corp', '+1-555-0123');
166+
INSERT INTO hubspot_datasource.contacts (email, firstname, phone)
167+
VALUES ('john.doe@example.com', 'John', '+1234567890');
199168

200169
-- Create new deal
201-
INSERT INTO hubspot_datasource.deals (dealname, amount, pipeline, dealstage)
202-
VALUES ('Acme Software License', '50000', 'sales', 'qualified-to-buy');
170+
INSERT INTO hubspot_datasource.deals (dealname, amount, dealstage, pipeline)
171+
VALUES ('New Deal', 5000, 'presentationscheduled', 'default');
203172
```
204173

205174
**Updating Records:**
206175
```sql
207176
-- Update company information
208177
UPDATE hubspot_datasource.companies
209-
SET industry = 'SaaS', city = 'Austin'
178+
SET industry = 'COMPUTER_SOFTWARE', city = 'Austin'
210179
WHERE name = 'Acme Corp';
211180

212181
-- Update contact details
@@ -216,18 +185,18 @@ WHERE email = 'john.doe@acme.com';
216185

217186
-- Move deal through pipeline
218187
UPDATE hubspot_datasource.deals
219-
SET dealstage = 'proposal-made', amount = '75000'
220-
WHERE dealname = 'Acme Software License';
188+
SET dealstage = '110382973', amount = '75000'
189+
WHERE dealname = 'New Deal';
221190
```
222191

223192
**Deleting Records:**
224193
```sql
225194
-- Archive old deals
226195
DELETE FROM hubspot_datasource.deals
227-
WHERE dealstage = 'closed-lost'
196+
WHERE dealstage = 'closedlost'
228197
AND createdate < '2023-01-01';
229198

230199
-- Remove test contacts
231200
DELETE FROM hubspot_datasource.contacts
232-
WHERE email LIKE '%test%' OR email LIKE '%example%';
201+
WHERE email = 'email';
233202
```

0 commit comments

Comments
 (0)