// TableDefinitionQuery returns a query with table structure
765365
func (adapter *PostgresAdapter) TableDefinitionQuery() string {
	query := `
		SELECT
			%s,%s,%s,%s
		FROM
			%s.%s
		WHERE
			%s = $1
		ORDER BY
			%s;`

	return Cleanf(query,
		types.SQLColumnLabelColumnName, types.SQLColumnLabelColumnType, // select
		types.SQLColumnLabelColumnLength, types.SQLColumnLabelPrimaryKey, // select
		adapter.Schema, types.SQLDictionaryTableName, // from
		types.SQLColumnLabelTableName,   // where
		types.SQLColumnLabelColumnOrder) // order by

}
1198292
func (s *Endpoint) SetExternalTableDefinition(v string) *Endpoint {
	s.ExternalTableDefinition = &v
	return s
}
30237
func FormatDefinition(definition []string, count int) string {
	var buffer bytes.Buffer

	spacer := strings.Repeat(" ", count)

	for i, d := range definition {
		if i == 0 {
			buffer.WriteString(d)
			buffer.WriteString("\n")
		} else {
			buffer.WriteString(spacer)
			buffer.WriteString(d)
			buffer.WriteString("\n")
		}
	}

	return strings.TrimSuffix(buffer.String(), "\n")
}
1200473
func IsDefinition(s spec.Schema) bool {
	return len(s.SchemaProps.Ref.GetPointer().String()) > 0
}
958584
func (s *CreateTaskSetInput) SetTaskDefinition(v string) *CreateTaskSetInput {
	s.TaskDefinition = &v
	return s
}
1318060
func responseDefinition() (*design.ResponseDefinition, bool) {
	r, ok := dslengine.CurrentDefinition().(*design.ResponseDefinition)
	if !ok {
		dslengine.IncompatibleDSL()
	}
	return r, ok
}
533702
func (s *UpdateServiceInput) SetTaskDefinition(v string) *UpdateServiceInput {
	s.TaskDefinition = &v
	return s
}
842314
func (s *ImportJobResponse) SetDefinition(v *ImportJobResource) *ImportJobResponse {
	s.Definition = v
	return s
}
879268
func (f *RelationalModelDefinition) StructDefinition() string {
	header := fmt.Sprintf("type %s struct {\n", f.ModelName)
	var output string
	f.IterateFields(func(field *RelationalFieldDefinition) error {
		output = output + field.FieldDefinition()
		return nil
	})

	// Get a sortable slice of BelongsTo relationships
	var keys []string
	for k := range f.BelongsTo {
		keys = append(keys, k)
	}
	sort.Strings(keys)

	for _, k := range keys {
		output = output + f.BelongsTo[k].ModelName + "\t" + f.BelongsTo[k].ModelName + "\n"
	}
	footer := "}\n"
	return header + output + footer
}
602568
func (e *Job) MatchesDefinition(def catalog.Definition) bool {
	return e.JobID == def.JobID &&
		e.Flavor == def.Flavor &&
		e.Schedule == def.Schedule &&
		e.Acls.Equal(&def.Acls) &&
		bytes.Equal(e.Task, def.Task) &&
		bytes.Equal(e.TriggeringPolicyRaw, def.TriggeringPolicy) &&
		equalSortedLists(e.TriggeredJobIDs, def.TriggeredJobIDs)
}
1307398
func (ts *TableSpec) AddIndex(id *IndexDefinition) {
	ts.Indexes = append(ts.Indexes, id)
}
1319963
func (db *SQLDB) getSysTablesDefinition() types.EventTables {
	return types.EventTables{
		types.SQLLogTableName: {
			Name: types.SQLLogTableName,
			Columns: []*types.SQLTableColumn{
				{
					Name:    types.SQLColumnLabelId,
					Type:    types.SQLColumnTypeSerial,
					Primary: true,
				},
				{
					Name:    types.SQLColumnLabelTimeStamp,
					Type:    types.SQLColumnTypeTimeStamp,
					Primary: false,
				},
				{
					Name:    types.SQLColumnLabelTableName,
					Type:    types.SQLColumnTypeVarchar,
					Length:  100,
					Primary: false,
				},
				{
					Name:    types.SQLColumnLabelEventName,
					Type:    types.SQLColumnTypeVarchar,
					Length:  100,
					Primary: false,
				},
				{
					Name:    types.SQLColumnLabelEventFilter,
					Type:    types.SQLColumnTypeVarchar,
					Length:  100,
					Primary: false,
				},
				// We use varchar for height - there is no uint64 type though numeric could have been used. We obtain the
				// maximum height by maxing over the serial ID type
				{
					Name:    types.SQLColumnLabelHeight,
					Type:    types.SQLColumnTypeVarchar,
					Length:  100,
					Primary: false,
				},
				{
					Name:    types.SQLColumnLabelTxHash,
					Type:    types.SQLColumnTypeVarchar,
					Length:  txs.HashLengthHex,
					Primary: false,
				},
				{
					Name:    types.SQLColumnLabelAction,
					Type:    types.SQLColumnTypeVarchar,
					Length:  20,
					Primary: false,
				},
				{
					Name:    types.SQLColumnLabelDataRow,
					Type:    types.SQLColumnTypeJSON,
					Length:  0,
					Primary: false,
				},
				{
					Name:    types.SQLColumnLabelSqlStmt,
					Type:    types.SQLColumnTypeText,
					Length:  0,
					Primary: false,
				},
				{
					Name:    types.SQLColumnLabelSqlValues,
					Type:    types.SQLColumnTypeText,
					Length:  0,
					Primary: false,
				},
			},
			NotifyChannels: map[string][]string{types.BlockHeightLabel: {types.SQLColumnLabelHeight}},
		},
		types.SQLDictionaryTableName: {
			Name: types.SQLDictionaryTableName,
			Columns: []*types.SQLTableColumn{
				{
					Name:    types.SQLColumnLabelTableName,
					Type:    types.SQLColumnTypeVarchar,
					Length:  100,
					Primary: true,
				},
				{
					Name:    types.SQLColumnLabelColumnName,
					Type:    types.SQLColumnTypeVarchar,
					Length:  100,
					Primary: true,
				},
				{
					Name:    types.SQLColumnLabelColumnType,
					Type:    types.SQLColumnTypeInt,
					Length:  0,
					Primary: false,
				},
				{
					Name:    types.SQLColumnLabelColumnLength,
					Type:    types.SQLColumnTypeInt,
					Length:  0,
					Primary: false,
				},
				{
					Name:    types.SQLColumnLabelPrimaryKey,
					Type:    types.SQLColumnTypeInt,
					Length:  0,
					Primary: false,
				},
				{
					Name:    types.SQLColumnLabelColumnOrder,
					Type:    types.SQLColumnTypeInt,
					Length:  0,
					Primary: false,
				},
			},
		},
		types.SQLChainInfoTableName: {
			Name: types.SQLChainInfoTableName,
			Columns: []*types.SQLTableColumn{
				{
					Name:    types.SQLColumnLabelChainID,
					Type:    types.SQLColumnTypeVarchar,
					Length:  100,
					Primary: true,
				},
				{
					Name:    types.SQLColumnLabelBurrowVer,
					Type:    types.SQLColumnTypeVarchar,
					Length:  100,
					Primary: false,
				},
			},
		},
	}
}
1074490
func (f RelationalModelDefinition) TableName() string {
	return inflect.Underscore(inflection.Plural(f.ModelName))
}
95782
func (in *TableColumnDefinition) DeepCopy() *TableColumnDefinition {
	if in == nil {
		return nil
	}
	out := new(TableColumnDefinition)
	in.DeepCopyInto(out)
	return out
}
730310
func (s *GetFunctionDefinitionVersionOutput) SetDefinition(v *FunctionDefinitionVersion) *GetFunctionDefinitionVersionOutput {
	s.Definition = v
	return s
}
649526
func TableFromInstance(object DomainObject) (*Table, error) {
	elem := reflect.TypeOf(object).Elem()

	t := &Table{
		StructName: elem.Name(),
		ColToField: map[string]string{},
		FieldToCol: map[string]string{},
		EntityDefinition: EntityDefinition{
			Columns: []*ColumnDefinition{},
			Indexes: map[string]*IndexDefinition{},
		},
	}
	for i := 0; i < elem.NumField(); i++ {
		structField := elem.Field(i)
		if len(structField.PkgPath) > 0 { // skip unexported fields
			continue
		}
		tag := strings.TrimSpace(structField.Tag.Get(dosaTagKey))
		if tag == "-" { // skip explicitly ignored fields
			continue
		}
		name := structField.Name
		if name == entityName {
			var err error
			if t.EntityDefinition.Name, t.TTL, t.ETL, t.Key, err = parseEntityTag(t.StructName, tag); err != nil {
				return nil, err
			}
		} else {
			// parse index fields
			if structField.Type == indexType {
				indexName, indexKey, err := parseIndexTag(structField.Name, tag)
				if err != nil {
					return nil, err
				}
				if _, exist := t.Indexes[indexName]; exist {
					return nil, errors.Errorf("index name is duplicated: %s", indexName)
				}
				t.Indexes[indexName] = &IndexDefinition{Key: indexKey}
			} else {
				cd, err := parseFieldTag(structField, tag)
				if err != nil {
					return nil, errors.Wrapf(err, "column %q had invalid type", name)
				}
				t.Columns = append(t.Columns, cd)
				t.ColToField[cd.Name] = name
				t.FieldToCol[name] = cd.Name
			}
		}
	}

	if t.Key == nil {
		return nil, errors.Errorf("cannot find dosa.Entity in object %s", t.StructName)
	}

	translateKeyName(t)

	if err := t.EnsureValid(); err != nil {
		return nil, errors.Wrap(err, "failed to parse dosa object")
	}

	return t, nil
}
57402
func (s *UpdateTypeInput) SetDefinition(v string) *UpdateTypeInput {
	s.Definition = &v
	return s
}