Source
DataSource
Source code in blue/data/source.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | |
__init__(name, properties={})
Initialize a generic data source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the source. |
required |
properties
|
dict
|
Additional configuration properties. |
{}
|
Source code in blue/data/source.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
create_database(database, properties={})
Create a new database in the data source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Name of the new database. |
required |
properties
|
dict
|
Database-specific configuration options. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Metadata or result of the creation operation. Default is empty. |
Source code in blue/data/source.py
161 162 163 164 165 166 167 168 169 170 171 172 | |
create_database_collection(database, collection, properties={})
Create a new collection (schema, table group, or equivalent) in a database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Database name. |
required |
collection
|
str
|
Name of the new collection. |
required |
properties
|
dict
|
Collection-specific properties. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Metadata or result of the creation operation. Default is empty. |
Source code in blue/data/source.py
228 229 230 231 232 233 234 235 236 237 238 239 240 | |
create_database_collection_entity(database, collection, entity, properties={})
Create a new entity (table, object, or equivalent) within a collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Database name. |
required |
collection
|
str
|
Collection or schema name. |
required |
entity
|
str
|
Name of the entity to create. |
required |
properties
|
dict
|
Entity properties, including column definitions, types, and misc metadata such as primary keys. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Metadata or result of the creation operation. Default is empty. |
Source code in blue/data/source.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
create_database_collection_relation(database, collection, relation, properties={})
Create a new relationship between entities within a collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Database name. |
required |
collection
|
str
|
Collection or schema name. |
required |
relation
|
str
|
Name or identifier of the relation. |
required |
properties
|
dict
|
Relation-specific metadata. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Metadata or result of the creation operation. Default is empty. |
Source code in blue/data/source.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
execute_query(query, database=None, collection=None, optional_properties={})
Execute a query on the data source and return results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Query string to execute. |
required |
database
|
str
|
Target database name. |
None
|
collection
|
str
|
Target collection name. |
None
|
optional_properties
|
dict
|
Additional execution options. |
{}
|
Returns:
| Type | Description |
|---|---|
|
list[dict]: List of results, each row as a dictionary. Default is a single empty dictionary. |
Source code in blue/data/source.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | |
fetch_collection_stats(database, collection_name, schema_json=None, sample_limit=None)
Retrieve statistics for a specific collection (schema) in a database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Database name. |
required |
collection_name
|
str
|
Collection or schema name. |
required |
schema_json
|
dict
|
Schema definition for computing statistics. |
None
|
sample_limit
|
int
|
Maximum number of samples to collect for properties. |
None
|
Returns:
| Type | Description |
|---|---|
|
dict or None: Collection-level statistics such as number of entities, relations, or sampled property values. Default is None. |
Source code in blue/data/source.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | |
fetch_database_collection_entities(database, collection)
Retrieve entities (tables, objects, or equivalent) for a specific collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Name of the database. |
required |
collection
|
str
|
Name of the collection or schema. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Dictionary of entities with their properties and metadata. Default is empty. |
Source code in blue/data/source.py
200 201 202 203 204 205 206 207 208 209 210 211 212 | |
fetch_database_collection_metadata(database, collection)
Fetch metadata for a collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Database name. |
required |
collection
|
str
|
Collection name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Collection metadata (default empty). |
Source code in blue/data/source.py
187 188 189 190 191 192 193 194 195 196 197 198 | |
fetch_database_collection_relations(database, collection)
Retrieve relationships (e.g., foreign keys or links) between entities in a collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Name of the database. |
required |
collection
|
str
|
Name of the collection or schema. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Dictionary of relations between entities. Default is empty. |
Source code in blue/data/source.py
214 215 216 217 218 219 220 221 222 223 224 225 226 | |
fetch_database_collections(database)
List all collections in a database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Database name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
Collection names (default empty). |
Source code in blue/data/source.py
175 176 177 178 179 180 181 182 183 184 185 | |
fetch_database_metadata(database)
Retrieve metadata for a specific database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Name of the database. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Database-level metadata such as size, owner, or creation date. Default is an empty dictionary. |
Source code in blue/data/source.py
135 136 137 138 139 140 141 142 143 144 145 146 | |
fetch_database_schema(database)
Retrieve the schema of a specific database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Name of the database. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Database schema including collections and entities. Default is an empty dictionary. |
Source code in blue/data/source.py
148 149 150 151 152 153 154 155 156 157 158 159 | |
fetch_database_stats(database)
Retrieve statistics for a specific database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Database name. |
required |
Returns:
| Type | Description |
|---|---|
|
dict or None: Database-level statistics such as size, table count, or other relevant metrics. Default is None. |
Source code in blue/data/source.py
315 316 317 318 319 320 321 322 323 324 325 326 | |
fetch_databases()
List all databases available in the data source.
Returns:
| Type | Description |
|---|---|
|
list[str]: Names of databases. Default is an empty list. |
Source code in blue/data/source.py
126 127 128 129 130 131 132 133 | |
fetch_entity_stats(database, collection, entity)
Retrieve statistics for a specific entity (table/object) in a collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Database name. |
required |
collection
|
str
|
Collection or schema name. |
required |
entity
|
str
|
Entity name. |
required |
Returns:
| Type | Description |
|---|---|
|
dict or None: Entity-level statistics such as row count, size, or other metrics. Default is None. |
Source code in blue/data/source.py
344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
fetch_metadata()
Retrieve high-level metadata about the data source.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Source metadata such as name, type, or description. Default is an empty dictionary. |
Source code in blue/data/source.py
105 106 107 108 109 110 111 112 113 | |
fetch_property_stats(database, collection, entity, property_name, sample_limit=None)
Retrieve statistics for a specific property (column/attribute) of an entity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Database name. |
required |
collection
|
str
|
Collection or schema name. |
required |
entity
|
str
|
Entity name. |
required |
property_name
|
str
|
Property/column name. |
required |
sample_limit
|
int
|
Maximum number of sample values to fetch. |
None
|
Returns:
| Type | Description |
|---|---|
|
dict or None: Property-level statistics such as count, distinct values, null count, min/max, or sampled values. Default is None. |
Source code in blue/data/source.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | |
fetch_schema()
Retrieve the overall schema of the data source.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Schema definition including databases, collections, and entities. Default is an empty dictionary. |
Source code in blue/data/source.py
115 116 117 118 119 120 121 122 123 | |
fetch_source_stats()
Retrieve high-level statistics about the source itself.
Returns:
| Type | Description |
|---|---|
|
dict or None: Source-level statistics such as connection info, number of databases, or performance metrics. Default is None. |
Source code in blue/data/source.py
304 305 306 307 308 309 310 311 312 313 | |