Skip to main content

Pinecone Connector - Complete Implementation

All Phases Complete: 1, 2, and 3​

Project Overview​

A fully functional DataHub connector for Pinecone vector database that extracts metadata about indexes, namespaces, and automatically infers schemas from vector metadata.


File Structure​

metadata-ingestion/src/datahub/ingestion/source/pinecone/
├── __init__.py # Module initialization
├── config.py # Configuration model
├── pinecone_client.py # Pinecone SDK wrapper
├── pinecone_source.py # Main source implementation
├── report.py # Reporting and statistics
├── schema_inference.py # Schema inference engine (Phase 3)
├── README.md # User documentation
└── skill_docs/
├── PINECONE_CONNECTOR_PLANNING.md
├── PINECONE_CONNECTOR_IMPLEMENTATION.md
└── PINECONE_datahub-connector-pr-review-2026-03-08.md

metadata-ingestion/examples/recipes/
└── pinecone_to_datahub.yml # Example recipe

metadata-ingestion/tests/unit/
└── test_pinecone_source.py # Comprehensive unit tests

Integration:
├── setup.py # Plugin registration + dependencies
└── src/datahub/ingestion/source/common/subtypes.py # Container subtypes

Phase 1: Core Functionality​

Features​

  • Index discovery via Pinecone API
  • Index metadata extraction (dimension, metric, type, host, status)
  • Container workunits for indexes
  • Support for serverless and pod-based indexes
  • Index filtering patterns
  • Error handling and reporting

Key Components​

  • PineconeConfig - Configuration with API key, filtering, performance settings
  • PineconeClient.list_indexes() - Discover all indexes
  • PineconeSource._generate_index_container() - Create index containers

Phase 2: Namespace Support​

Features​

  • Namespace discovery using describe_index_stats()
  • Namespace containers with parent relationships
  • Dataset workunits representing vector collections
  • Namespace filtering patterns
  • Default namespace handling
  • Complete container hierarchy

Key Components​

  • PineconeClient.list_namespaces() - List namespaces with vector counts
  • PineconeSource._generate_namespace_container() - Create namespace containers
  • PineconeSource._generate_namespace_dataset() - Create dataset workunits

Entity Hierarchy​

Platform: pinecone
├── Container (Index) - PINECONE_INDEX
│ ├── Properties: dimension, metric, index_type, host, status
│ └── Container (Namespace) - PINECONE_NAMESPACE
│ ├── Properties: vector_count, index_name
│ └── Dataset (Vector Collection)
│ ├── Properties: dimension, metric, vector_count
│ └── Schema: Inferred from metadata (Phase 3)

Phase 3: Schema Inference​

Features​

  • Vector sampling with fallback strategies
  • Metadata field discovery
  • Type inference (string, number, boolean, array, object)
  • Field frequency tracking
  • Mixed type handling
  • Schema field generation with descriptions
  • Configurable sampling size and field limits

Key Components​

1. Schema Inference Engine (schema_inference.py)

class MetadataSchemaInferrer:
- infer_schema() - Main inference method
- _collect_field_statistics() - Gather field stats
- _infer_field_type() - Detect field types
- _select_primary_type() - Handle mixed types
- _generate_schema_fields() - Create SchemaField objects

2. Enhanced Vector Sampling (pinecone_client.py)

- sample_vectors() - Main sampling method with fallbacks
- _list_vector_ids() - List IDs using list() API
- _fetch_vectors() - Fetch with metadata using fetch() API
- _query_sample_vectors() - Fallback using query() API

3. Schema Integration (pinecone_source.py)

- _infer_schema() - Orchestrate schema inference
- Emit SchemaMetadata workunits
- Handle inference failures gracefully

Sampling Strategy​

Three-tier fallback:

  1. Primary: list() + fetch() (deterministic)
  2. Fallback: query() with dummy vector
  3. Graceful: Continue without schema if both fail

Type Detection​

Python TypeInferred TypeDataHub Type
strstringStringTypeClass
int, floatnumberNumberTypeClass
boolbooleanBooleanTypeClass
listarrayArrayTypeClass
dictobject(StringTypeClass)
Nonenull(StringTypeClass)

Schema Field Example​

SchemaField(
fieldPath="[version=2.0].category",
type=StringTypeClass(),
nativeDataType="string",
description="Appears in 100.0% of vectors. Examples: A, B, C",
nullable=True
)

Configuration​

Complete Configuration Example​

source:
type: pinecone
config:
api_key: "${PINECONE_API_KEY}"
environment: "us-west1-gcp"
platform_instance: "production"
env: "PROD"
index_pattern:
allow:
- "prod-.*"
- "customer-.*"
deny:
- ".*-test"
- ".*-dev"
namespace_pattern:
allow:
- "customer-.*"
deny:
- "internal-.*"
enable_schema_inference: true
schema_sampling_size: 100
max_metadata_fields: 100
max_workers: 5
stateful_ingestion:
enabled: true
remove_stale_metadata: true

sink:
type: datahub-rest
config:
server: "http://localhost:8080"

Configuration Options​

OptionTypeDefaultDescription
api_keystringRequiredPinecone API key
environmentstringNoneFor pod-based indexes
index_patternAllowDenyPatternAllow allFilter indexes
namespace_patternAllowDenyPatternAllow allFilter namespaces
enable_schema_inferencebooleantrueEnable schema inference
schema_sampling_sizeint100Vectors to sample
max_metadata_fieldsint100Max schema fields
max_workersint5Parallel workers
platform_instancestringNonePlatform instance ID
envstring"PROD"Environment
stateful_ingestionobjectNoneStateful config

Testing​

Unit Tests​

Test Coverage:

  • Configuration validation
  • Client initialization
  • Index listing and filtering
  • Namespace discovery
  • Schema inference engine
  • Type detection
  • Mixed type handling
  • Workunit generation
  • Error handling

Run Tests:

pytest tests/unit/test_pinecone_source.py -v

Test Classes:

  1. TestPineconeConfig - Configuration tests
  2. TestPineconeClient - Client wrapper tests
  3. TestPineconeSource - Source integration tests
  4. TestMetadataSchemaInferrer - Schema inference tests
  5. TestPineconeSourceWithSchemaInference - End-to-end tests

Manual Testing​

export PINECONE_API_KEY="your-api-key"
datahub ingest -c examples/recipes/pinecone_to_datahub.yml

Capabilities​

CapabilityStatusDescription
Platform InstanceYesMulti-environment support
ContainersYesIndex and namespace hierarchy
Schema MetadataYesInferred from vector metadata
Deletion DetectionYesVia stateful ingestion
Data ProfilingNoNot applicable
Usage StatsNoNot available from API
LineageNoFuture enhancement

Performance​

Ingestion Speed​

ScenarioTimeNotes
1 index, 1 namespace~5-10 secIncluding schema inference
10 indexes, 50 namespaces~2-5 minParallel processing
100 indexes, 500 namespaces~20-30 minMay hit rate limits

Schema Inference Impact​

Sampling SizeTime per NamespaceAccuracy
50~1-2 secGood
100 (default)~2-3 secBetter
200~4-5 secBest

Dependencies​

Python Packages​

# setup.py
"pinecone": {"pinecone-client>=3.0.0,<6.0.0"}

Compatibility​

  • Pinecone SDK: 3.0+
  • Python: 3.8+
  • Index Types: Serverless and Pod-based
  • DataHub: Current version

Future Enhancements (Phase 4+)​

  1. Nested Field Support - Extract nested object fields, support dot notation
  2. Array Element Types - Infer types of array elements
  3. Field Statistics - Min/max for numbers, string length stats
  4. Performance Optimizations - Parallel namespace processing, caching
  5. Advanced Type Detection - Date/timestamp, URL/email, enum detection
  6. Usage Statistics - Query patterns, access logs
  7. Lineage - Connect to embedding models, track data sources

Support​

For issues or questions:


Status: Production Ready | Version: 1.0.0 | Last Updated: 2026