---json
{
"page_id": "jk1afqxcs5ezma9b68xo4"
}
---
====== Learning Tabulify - Step 4 - How to select Data Resources ======
===== Concepts =====
To [[docs:op:select|select a data resources]] such as a [[docs:resource:file|file]] or a [[docs:resource:sql_table|database table]], ''Tabulify'' uses the concept of:
* [[#data selector]]
* and [[#selection_with_dependencies|dependency]] (Do we select also the dependent ''data resources'')
This page goes through this concepts with explanation and examples.
===== Data Selector =====
A ''data selector'' is composed of two parts:
* a [[docs:common:globbing|glob pattern]]
* and a [[docs:connection:connection|connection]]
* separated by the ''@'' (at) sign.
A [[docs:flow:data_selector|data selector]] looks like that:
globPattern@connection
A [[docs:common:globbing|glob pattern]] permits to define the ''name'' or the ''path'' of the [[docs:resource:resource|data resource]] located in its [[docs:connection:connection#system|system connection]].
===== Normal Selection =====
For instance, with the [[docs:system:tpcds|internal TPC-DS data store]], the below [[docs:tabul:data:list|list command]] will select all [[docs:resource:sql_table|tables]] that ends with the term ''sales'' because the ''*'' character matches all characters.
tabul data list *sales@tpcds
where:
* ''tabul'' is the [[docs:tabul:tabul|main command line utility]]
* ''data'' is a [[docs:tabul:module|module]] (ie the [[docs:tabul:data:start|data module]])
* ''list'' is a [[docs:tabul:command|command]]
* ''*sales@tpcds'' is a [[docs:flow:data_selector|resource data selector]] that select [[docs:resource:resource|data resources]].
* ''tpcds'' defines the [[docs:connection:connection|connection]]
* ''*sales'' defines the [[docs:resource:sql_table|tables]] to look for with a [[docs:common:globbing|glob pattern]]. In our case all tables that finish with the word ''sales'' because ''*'' is the [[docs:common:globbing|globbing star]] and select all characters.
Output:
path media_type
------------- ------------
catalog_sales sql/relation
store_sales sql/relation
web_sales sql/relation
To get more practice on ''glob pattern'', you can have a look at this page. [[howto:tabul:glob]]
===== Selection with dependencies =====
When moving data due to [[docs:resource:fkey|foreign-key constraint]], you need to move the data resources and their [[docs:resource:dependency|dependencies]].
That's why ''Tabulify'' offers the ''%%--with-dependencies%%'' [[docs:tabul:flag|flag]] that will select also the [[docs:resource:dependency|dependent resources]] of the selected [[docs:resource:resource|data resource]]
Example: All ''tables'' that have a name that ends with ''sales'' in the [[docs:system:tpcds|tpcds system]] and their [[docs:resource:dependency|dependent tables]]
tabul data list --with-dependencies *sales@tpcds
path media_type
---------------------- ------------
call_center sql/relation
catalog_page sql/relation
catalog_sales sql/relation
customer sql/relation
customer_address sql/relation
customer_demographics sql/relation
date_dim sql/relation
household_demographics sql/relation
income_band sql/relation
item sql/relation
promotion sql/relation
ship_mode sql/relation
store sql/relation
store_sales sql/relation
time_dim sql/relation
warehouse sql/relation
web_page sql/relation
web_sales sql/relation
web_site sql/relation
===== Local File System =====
The connection part of a [[docs:flow:data_selector|data selector]] is not mandatory as the default connection is the [[docs:connection:cd|local file system]].
Therefore, performing the [[docs:tabul:data:list|list command]] with a [[docs:flow:data_selector|data selector]] without ''connection'' will give you a list of the file in your current directory.
tabul data list *
path
-----------------------
README.md
characters.csv
date_dim--generator.yml
sequence--generator.yml
This is then the equivalent of the [[wp>Ls|ls command]]
===== Next =====
Now that we know how to select [[docs:resource:resource|data resources]], the next page will show you how to print their content.
[[5_print_data_resource|How to print Data Resources]]