How to define and use common values inside multiple model properties in dbt - dbt

I have model properties file defined in .yml and query defined in .sql. There are many models and there are some properties which are shared across models. So for instance I have used meta tag in .yml model property file and need to define a value let say a: . Now this is used across multiple model meta's. How can I define and use t hem in the dbt model properties file?

Variables not only works in .sql but also works in .yml in the model properties file. Here one sample of it
https://github.com/dbt-labs/dbt-core/pull/2015
works

Related

Define variables per folder in dbt

I'm trying to have a structure to run a dbt project, where I have multiple entities (bank, names, cars). I'm going to have exactly the same code for them all.
Based on that, I'm trying to have several folder with the same code, where I can define inside the dbt_project.yamlfile. The idea is something like this:
vars:
db_name: 'db_official'
staging:
bank: 'variable_bank'
car: 'variable_car'
name: 'variable_name'
The variable "db_name" works. So, my the two problems I'm having are:
How to have this structure inside the the yaml file?
How to reference this structure inside each file?
(extra) Any other ideas how to handle this?
Thanks!
vars are basically globals. They can be scoped to your whole project, or to a package within your project, but not more specifically than that (they share a flat namespace). See the docs.
I would pull out the common code into a macro, then call that macro from each model file, passing in the unique values as string literals in the model file:
-- models/staging/bank.sql
{{ my_model_template('variable_bank') }}
-- models/staging/car.sql
{{ my_model_template('variable_car') }}

How to use Global Property name in my JSON input request using SoapUI?

I have a SoapUI project which contains around 60 plus services. Each service requires some input which will be changed for every execution. So I have created certain Global Properties and assign some values to that properties.
I have to use these properties values in my SoapUI request ( i.e. JSON Format request ).
If it is groovy script means, I will use like this.
String HTiC_Username = com.eviware.soapui.model.propertyexpansion.PropertyExpansionUtils.globalProperties['HTiC_Username'].value;
But, how to get the value of the Global Property in the request?
Hope you understand my question. Please provide proper guidance.
Thanks
To dynamically "expand" (i.e. substitute) the value of a property into a test step, the following syntax is used: ${#scope#propertyName}
...where 'scope' refers to the level at which the property has been defined (e.g. Global, Project, TestSuite, TestCase).
So to expand a property named username defined as a Global property, for example, the following code can be used directly within a Request Test Step (e.g within a JSON body, or header value, etc):
${#Global#username}
To access the same property value within a Groovy Test Step, you can use the following syntax:
context.expand('${#scope#propertyName}')
...as in the following example:
context.expand('${#Global#username}')
What we did was the following:
created a test data file to store all the specific input data for the different services (testdata.properties)
Example content of testdata.properties:
Billing_customerID=1234567
OtherService_paymentid=12121212
....
create a SoupUi global parameter (File/Preferences/Global properties): testdata_filepath=C:\...
For specific services we added a Properties test step. You can specify the "Load from" field to our new global parameter: ${#Global#testdata_filepath} Now you can use the Load button to load parameters.
Finally you can reference the parameter in your xml in the following format: ${Properties#Billing_customerID}
Example content of a service with parameter:
...
<BillingCustomerIdentification>
<BillingCustomerID>${#Properties#Billing_customerID}</BillingCustomerID>
</BillingCustomerIdentification>
...
To set up your projects in this manner also helps to automate service tests eg. using Hudson (see my previous SO answer).
If it is too heavy and automation is not a target, you can simply use ${#Global#someinputvariable} format in your xml ;-)

generic path for arbitrary model

In my step-definition, I want to create a path to a named route for an arbitrary Model, like so:
Given(/^a new "(.*?)" form$/) do |model|
path = send("new_admin_#{model.downcase}_path".to_sym)
visit path
end
Used as
Given a new "Image" form
Given a new "User" form
I recall using a helper method in the past for this, one that allowed me to pass a modelname and some additional options, like the action and object or IDs. But I cannot find that anymore. This is for Rails 3.2.x.
Is there such a "magic" helper? If so, what is it? If not, are there common patterns to create paths to arbitrary Models?

Django - Custom Sql for the User model

Which name need the sql-file in the sql folder? When I want to load custom sql for the User Model.
Initial SQL Data
From the link you provided :
The hook is simple: Django just looks for a file called sql/modelname.sql, in your app directory, where modelname is the model's name in lowercase.
So, if you had a Person model in an app called myapp, you could add arbitrary SQL to the file sql/person.sql inside your myapp directory. Here's an example of what the file might contain:

How to Customise Magento Enterprise Customer Segments?

Do I
1) overide all Enterprise/CustomerSegment
then slot in the classes I need to add my own conditions and classes for models to build the DB queries
2) 1) seems bulky, how would I just add my new condition classes into a local folder?
The solution is to override only the models, and leave the block, controller using Enterprise_CustomerSegment module.
These files would be required to update the CustomerSegment module to add a standing order report:
CustomModule/CustomerSegment/etc/config.xml (with all the model 's)
CustomModule/CustomerSegment/Model/Condition/Combine/Abstract.php
(this may not need to be overridden)
CustomModule/CustomerSegment/Model/Segment/Condition/Combine/Root.php
CustomModule/CustomerSegment/Model/Segment/Condition/Standingorder/Frequency.php
CustomModule/CustomerSegment/Model/Segment/Condition/Combine.php
CustomModule/CustomerSegment/Model/Segment/Condition/Standingorder.php
CustomModule/CustomerSegment/Model/Segment.php
(this may not need to be overridden)