Repository: honeycombio/terraform-provider-honeycombio (language: python)

Issue:
query specification making use of "ascending" sort order always showing diff
Related HCL:

```hcl
data "honeycombio_query_specification" "query" {
  breakdowns  = ["hostname"]

  calculation {
    op     = "MAX"
    column = "counter"
  }
  
  order {
    column = "hostname"
    order  = "ascending"
  }
}

resource "honeycombio_query" "myquery" {
  dataset    = "my-dataset"
  query_json = data.honeycombio_query.query.json
}
```

plan output:
```
-/+ resource "honeycombio_query" "myquery" {
      ~ id         = "58cMt8rSrsc" -> (known after apply)
      ~ query_json = jsonencode(
          ~ {
              ~ orders       = [
                  ~ {
                      + order  = "ascending"
                        # (1 unchanged element hidden)
                    },
                ]
                # (4 unchanged elements hidden)
            } # forces replacement
        )
        # (1 unchanged attribute hidden)
    }
```


Discussion / hints:

Fix patch:
diff --git a/honeycombio/data_source_query_specification.go b/honeycombio/data_source_query_specification.go
index 47b9f990..40c0344e 100644
--- a/honeycombio/data_source_query_specification.go
+++ b/honeycombio/data_source_query_specification.go
@@ -422,7 +422,14 @@ func extractOrders(d *schema.ResourceData) []honeycombio.OrderSpec {
 
 		so, ok := d.GetOk(fmt.Sprintf("order.%d.order", i))
 		if ok {
-			order.Order = honeycombio.SortOrderPtr(honeycombio.SortOrder(so.(string)))
+			ov := honeycombio.SortOrder(so.(string))
+			// ascending is the default, API doesn't return or require
+			// the field unless value is descending
+			//
+			// not sending to avoid constant plan diffs
+			if ov != honeycombio.SortOrderAsc {
+				order.Order = honeycombio.SortOrderPtr(ov)
+			}
 		}
 
 		// TODO: validation


Test patch:
diff --git a/honeycombio/data_source_query_specification_test.go b/honeycombio/data_source_query_specification_test.go
index dd65d15c..a82853a0 100644
--- a/honeycombio/data_source_query_specification_test.go
+++ b/honeycombio/data_source_query_specification_test.go
@@ -62,7 +62,7 @@ data "honeycombio_query_specification" "test" {
     }
     order {
         column = "column_1"
-        order  = "descending"
+        order  = "ascending"
     }
 
     having {
@@ -124,8 +124,7 @@ const expectedJSON string = `{
       "column": "duration_ms"
     },
     {
-      "column": "column_1",
-      "order": "descending"
+      "column": "column_1"
     }
   ],
   "havings": [