Skip to content

Commit 74d92aa

Browse files
authored
Merge pull request #49 from coecms/info
Add "Info" view
2 parents ee82785 + 4a520fd commit 74d92aa

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

clef/model.py

+35
Original file line numberDiff line numberDiff line change
@@ -286,3 +286,38 @@ class C6Dataset(Base):
286286

287287
#:
288288
table_id = Column('table_id', Text)
289+
290+
291+
class Info(Base):
292+
"""
293+
General information about a dataset file
294+
295+
This is a database view, its columns shouldn't be used for searching as
296+
they are large and not indexed.
297+
"""
298+
__tablename__ = 'info_attributes'
299+
300+
file_id = Column(UUID,
301+
ForeignKey('metadata.md_hash'),
302+
ForeignKey('checksums.ch_hash'),
303+
ForeignKey('esgf_paths.file_id'),
304+
primary_key=True)
305+
306+
#:
307+
variant_info = Column(Text)
308+
#:
309+
source = Column(Text)
310+
#:
311+
parent_experiment_id = Column(Text)
312+
#:
313+
further_info_url = Column(Text)
314+
#:
315+
contact = Column(Text)
316+
#:
317+
title = Column(Text)
318+
#:
319+
description = Column(Text)
320+
#:
321+
license = Column(Text)
322+
#:
323+
tracking_id = Column(Text)

db/tables.sql

+18
Original file line numberDiff line numberDiff line change
@@ -359,3 +359,21 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS extended_metadata AS
359359
NATURAL LEFT JOIN extended_metadata_manual AS m;
360360
GRANT SELECT ON extended_metadata TO PUBLIC;
361361
CREATE UNIQUE INDEX IF NOT EXISTS extended_metadata_file_id ON extended_metadata(file_id);
362+
363+
/*
364+
* Information-only attributes that are useful to know but won't be searched on
365+
*/
366+
CREATE OR REPLACE VIEW info_attributes AS
367+
SELECT
368+
md_hash as file_id,
369+
md_json->'attributes'->>'variant_info' as variant_info,
370+
md_json->'attributes'->>'source' as source,
371+
md_json->'attributes'->>'parent_experiment_id' as parent_experiment_id,
372+
md_json->'attributes'->>'further_info_url' as further_info_url,
373+
md_json->'attributes'->>'contact' as contact,
374+
md_json->'attributes'->>'title' as title,
375+
md_json->'attributes'->>'description' as description,
376+
md_json->'attributes'->>'license' as license,
377+
md_json->'attributes'->>'tracking_id' as tracking_id
378+
FROM metadata
379+
WHERE md_type = 'netcdf';

0 commit comments

Comments
 (0)